Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to call VFP function from .NET C# code?
Message
 
 
À
05/01/2015 11:09:55
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:
01613079
Vues:
59
>>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)

Thank you very much.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform