示例#1
0
        internal static string Decrypt(string toDecrypt, string key)
        {
            byte[]          bytes           = Encoding.UTF8.GetBytes(key);
            byte[]          inputBuffer     = Base32String.Decode(toDecrypt);
            RijndaelManaged rijndaelManaged = new RijndaelManaged();

            rijndaelManaged.Key     = bytes;
            rijndaelManaged.Mode    = CipherMode.ECB;
            rijndaelManaged.Padding = PaddingMode.PKCS7;
            return(Encoding.UTF8.GetString(rijndaelManaged.CreateDecryptor().TransformFinalBlock(inputBuffer, 0, inputBuffer.Length)));
        }
示例#2
0
        internal static string Encrypt(string toEncrypt, string key)
        {
            byte[]          bytes1          = Encoding.UTF8.GetBytes(key);
            byte[]          bytes2          = Encoding.UTF8.GetBytes(toEncrypt);
            RijndaelManaged rijndaelManaged = new RijndaelManaged();

            rijndaelManaged.Key     = bytes1;
            rijndaelManaged.Mode    = CipherMode.ECB;
            rijndaelManaged.Padding = PaddingMode.PKCS7;
            return(Base32String.Encode(rijndaelManaged.CreateEncryptor().TransformFinalBlock(bytes2, 0, bytes2.Length)));
        }