Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static RNGCryptoServiceProvider rngCsp = new RNGCryptoServiceProvider();
- public static string IV = "mvi4j0r32sdf4gj8"; // 16 chars = 128 bits
- public static string Key = "h564j9z4j5h4j6z48g68h4j8gz84jz8g"; // 32 chars = 256 bits
- byte[] IVrandom = new byte[16];
- public static string Encrypt(string decrypted)
- {
- byte[] IVrandom = new byte[16];
- byte[] textbytes = ASCIIEncoding.ASCII.GetBytes(decrypted);
- AesCryptoServiceProvider encdec = new AesCryptoServiceProvider();
- encdec.BlockSize = 128;
- encdec.KeySize = 256;
- encdec.Key = ASCIIEncoding.ASCII.GetBytes(Key);
- encdec.IV = ASCIIEncoding.ASCII.GetBytes(IV);
- encdec.Padding = PaddingMode.PKCS7;
- encdec.Mode = CipherMode.CBC;
- ICryptoTransform icrypt = encdec.CreateEncryptor(encdec.Key, encdec.IV);
- byte[] enc = icrypt.TransformFinalBlock(textbytes, 0, textbytes.Length);
- icrypt.Dispose();
- return Convert.ToBase64String(enc);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement