Skip to content

Instantly share code, notes, and snippets.

@smathy
Created February 9, 2012 18:30
Show Gist options
  • Save smathy/1781848 to your computer and use it in GitHub Desktop.
Save smathy/1781848 to your computer and use it in GitHub Desktop.
public string encriptaRijndael(string ccNum)
{
IniFile ini = new IniFile("C:\\Adquira/config/Rijndael.properties");
byte[] keyArray = UTF8Encoding.Default.GetBytes(ini.IniReadValue("Info", "KEY"));
byte[] resultArray = new byte[0];
byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(ccNum);
try
{
if (keyArray.Length > 0)
{
RijndaelManaged rDel = new RijndaelManaged();
rDel.Key = keyArray;
rDel.Mode = CipherMode.ECB;
rDel.Padding = PaddingMode.Zeros;
ICryptoTransform cTransform = rDel.CreateEncryptor();
resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
}
}
catch (Exception)
{
//("ERROR EN EL CIFRADO (Rijndael).");
}
return Convert.ToBase64String(resultArray, 0, resultArray.Length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment