Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFPEncryption x C#
Message
De
02/03/2015 12:32:52
Emerson Reed
Folhamatic Tecnologia Em Sistemas
Americana - São Paulo, Brésil
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Titre:
VFPEncryption x C#
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01616094
Message ID:
01616094
Vues:
61
Hi folks!
I need some help to translate this C# code to VFP/vfpEncryption71.fll:

Encrypt("Text to be encrypted", "myPassword12");

public static string Encrypt(string texto, string Password)
{
if (string.IsNullOrEmpty(texto))
{
return texto;
}
RijndaelManaged RijndaelCipher = new RijndaelManaged();
byte[] PlainText = System.Text.Encoding.Unicode.GetBytes(texto);
byte[] Salt = Encoding.ASCII.GetBytes(Password.Length.ToString());
PasswordDeriveBytes SecretKey = new PasswordDeriveBytes(Password, Salt);
//Creates a symmetric encryptor object.
ICryptoTransform Encryptor = RijndaelCipher.CreateEncryptor(SecretKey.GetBytes(32), SecretKey.GetBytes(16));
MemoryStream memoryStream = new MemoryStream();
//Defines a stream that links data streams to cryptographic transformations
CryptoStream cryptoStream = new CryptoStream(memoryStream, Encryptor, CryptoStreamMode.Write);
cryptoStream.Write(PlainText, 0, PlainText.Length);
//Writes the final state and clears the buffer
cryptoStream.FlushFinalBlock();
byte[] CipherBytes = memoryStream.ToArray();
memoryStream.Close();
cryptoStream.Close();
string EncryptedData = Convert.ToBase64String(CipherBytes);
return EncryptedData;
}

I'm trying this way (without success):

Clear
? "VFP value = ", vfpEncrypt("Text to be encrypted", "myPassword12")
? "C# value = ", "EI4wZndNJXck6qLTtDK5V+W48SOoKhrqOK0HOgH+T9qZVOALnI+okvROXlDT/Jbv"
Return

Function vfpEncrypt
Lparameters lcText, lcPassword
Set Library To (Locfile("vfpencryption71.fll", "FLL"))
Return Strconv(Encrypt(m.lcText, m.lcPassword, 2, 2, 2, 256, 128, ""),13)
Endfunc

Please, someone could help me?
Emerson Santon Reed
"One Developer CAN Make a Difference. A community CAN make a future." - Craig Boyd
Répondre
Fil
Voir

Click here to load this message in the networking platform