Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to call VFP function from .NET C# code?
Message
De
06/01/2015 14:24:27
John Baird
Coatesville, Pennsylvanie, États-Unis
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01612997
Message ID:
01613181
Vues:
81
>>>I know my code works because I tested it and it is in production at several customers. However, I will double check that I am not missing something important, based on your finding. Thank you.
>>
>>My slightly modified version of the Encrypt function:
        public string Encrypt(string tcStr, string tcPassword)
>>        {
>>            byte[] tcStrBytes = Encoding.ASCII.GetBytes(tcStr);
>>            int tcStrLength = tcStrBytes.Length;
>>
>>            string lcPassword = tcPassword + ((char) 0).ToString();
>>            byte[] lcPasswordBytes = Encoding.ASCII.GetBytes(lcPassword);
>>
>>            int lnPassLen = lcPasswordBytes.Length;
>>            int lnPassPos = 0;
>> 
>>            string lcStrOut = string.Empty;
>>
>>            int lnPassNum = ((CipherGetPnum(tcPassword)/997 - 1)%254) + 1;
>>
>>            for (int i = 0; i < tcStrLength; i++)
>>            {
>>                int lnNum01 = ((lnPassNum + (i - tcStrLength)) - 1);
>>                lnPassNum = (Math.Abs(lnNum01)%254)*Math.Sign(lnNum01) + 1;
>>                var lnByte = tcStrBytes[i] ^ (lnPassNum ^ lcPasswordBytes[lnPassPos]);
>>                lcStrOut = lcStrOut + Convert.ToChar(lnByte==0 ? tcStrBytes[i] : lnByte & 0xFF);
>>                lnPassPos = lnPassPos > lnPassLen ? 0 : lnPassPos + 1;
>>            }
>>            return lcStrOut;
>>        }
Quick test comparing results with the VFP version using string 'Test' and password 'Viv' shows identical results in VFP (returned asc values: 255,246,253,131) i.e. string length is 4. Your C# only returns first three values (i.e. string length 3)
>
>I am testing your code and mine code and neither one works :). I am sure it is me. Here is how I test it, please let me know if this is the correct approach:
>
>string cTest1 = "ABC123";
>string cTest1Encr;
>string cTest1Decr;
>cTest1Encr = Encrypt( cTest1, "123abc");
>cTest1Decr = Encrypt( cTest1Encr, "123abc");
>
>
>Shouldn't cTest1Decr show "ABC123"?

Aren't you encrypting the values instead of decrypting the 2nd?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform