public static string Decrypt(string cipherText, string masterKey) { byte[] cipherData = Convert.FromBase64String(cipherText); byte[] bytesFromString = StringUtils.GetBytesFromString(masterKey); PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(masterKey, new byte[13] { (byte)73, (byte)118, (byte)97, (byte)110, (byte)32, (byte)77, (byte)101, (byte)100, (byte)118, (byte)101, (byte)100, (byte)101, (byte)118 }); byte[] IV = !RijndaelCrypto.USE_CUSTOM_INIT_VECTOR ? passwordDeriveBytes.GetBytes(16) : Constants.CRYPTO_INIT_VECTOR; return(StringUtils.GetStringFromBytes(RijndaelCrypto.Decrypt(cipherData, bytesFromString, IV))); }
public static string Encrypt(string clearText, string masterKey) { byte[] bytesFromString1 = StringUtils.GetBytesFromString(clearText); byte[] bytesFromString2 = StringUtils.GetBytesFromString(masterKey); PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(masterKey, new byte[13] { (byte)73, (byte)118, (byte)97, (byte)110, (byte)32, (byte)77, (byte)101, (byte)100, (byte)118, (byte)101, (byte)100, (byte)101, (byte)118 }); byte[] IV = !RijndaelCrypto.USE_CUSTOM_INIT_VECTOR ? passwordDeriveBytes.GetBytes(16) : Constants.CRYPTO_INIT_VECTOR; return(Convert.ToBase64String(RijndaelCrypto.Encrypt(bytesFromString1, bytesFromString2, IV))); }