Beispiel #1
0
        public static string Encrypt(this HttpApplication app, string input)
        {
            IntitializeCrypto();
            var bytes = HashUtility.GenerateSalt(16).ToList();

            bytes.AddRange(Encoding.UTF8.GetBytes(input));
            return(Convert.ToBase64String(CryptoUtility.EncryptBytes(bytes.ToArray(), CryptKey, CryptIV)));
        }
Beispiel #2
0
        public static void PassphraseToSCryptKeyAndIV(string passphrase, out byte[] key, out byte[] iv)
        {
            var hashList = HashUtility.HashSCrypt(Encoding.UTF8.GetBytes(passphrase)).ToList();

            key = new byte[32];
            iv  = new byte[16];
            hashList.CopyTo(0, key, 0, 32);
            hashList.CopyTo(32, iv, 0, 16);
        }