public static String EncryptInt32(Int32 data, Byte[] key, Byte[] ivec)
{
String retVal = "";
try
{
ASCIIEncoding encoder = new ASCIIEncoding();
Byte[] inputInBytes = BitConverter.GetBytes(data);
AesCryptoServiceProvider aesProvider = new AesCryptoServiceProvider();
aesProvider.BlockSize = 128;
aesProvider.KeySize = 256;
ICryptoTransform cryptoTransform = aesProvider.CreateEncryptor(key, ivec);
MemoryStream encryptedStream = new MemoryStream();
CryptoStream cryptStream = new CryptoStream(encryptedStream, cryptoTransform, CryptoStreamMode.Write);
cryptStream.Write(inputInBytes, 0, inputInBytes.Length);
cryptStream.FlushFinalBlock();
encryptedStream.Position = 0;
Byte[] result = new byte[encryptedStream.Length];
encryptedStream.Read(result, 0, Convert.ToInt32(encryptedStream.Length));
cryptStream.Close();
retVal = Base64PlusStringEncode(result);
}
catch (Exception err)
{
throw new Exception("Halide.H3Secure Error: " + err.ToString());
}
return retVal;
}