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