示例#1
0
        public static string Encrypt(string text, string password)
        {
            byte[] bytes = Encoding.Unicode.GetBytes(text);
            PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(password, new byte[]
            {
                73,
                118,
                97,
                110,
                32,
                77,
                101,
                100,
                118,
                101,
                100,
                101,
                118
            });

            return(SCLEncrypt.ToString(SCLEncrypt.Encrypt(bytes, passwordDeriveBytes.GetBytes(32), passwordDeriveBytes.GetBytes(16))));
        }
示例#2
0
        public static string Decrypt(string cipher_text, string password)
        {
            byte[] cipherData = SCLEncrypt.ToByteArray(cipher_text);
            PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(password, new byte[]
            {
                73,
                118,
                97,
                110,
                32,
                77,
                101,
                100,
                118,
                101,
                100,
                101,
                118
            });

            byte[] bytes = SCLEncrypt.Decrypt(cipherData, passwordDeriveBytes.GetBytes(32), passwordDeriveBytes.GetBytes(16));
            return(Encoding.Unicode.GetString(bytes));
        }