コード例 #1
0
        public string Decrypt(EncryptedValue encryptedValue)
        {
            var aes = new AesManaged
            {
                Key = Convert.FromBase64String(_key),
                Mode = CipherMode.CBC,
                Padding = PaddingMode.ISO10126,
                IV = Convert.FromBase64String(encryptedValue.IV)
            };

            var decryptor = aes.CreateDecryptor();
            var passwordBytes = Convert.FromBase64String(encryptedValue.Value);

            var decryptedBytes = decryptor.TransformFinalBlock(passwordBytes, 0, passwordBytes.Length);
            return Encoding.UTF8.GetString(decryptedBytes);
        }
コード例 #2
0
        public string Decrypt(EncryptedValue encryptedValue)
        {
            var aes = new AesManaged
            {
                Key     = Convert.FromBase64String(_key),
                Mode    = CipherMode.CBC,
                Padding = PaddingMode.ISO10126,
                IV      = Convert.FromBase64String(encryptedValue.IV)
            };

            var decryptor     = aes.CreateDecryptor();
            var passwordBytes = Convert.FromBase64String(encryptedValue.Value);

            var decryptedBytes = decryptor.TransformFinalBlock(passwordBytes, 0, passwordBytes.Length);

            return(Encoding.UTF8.GetString(decryptedBytes));
        }
コード例 #3
0
 private static void DecryptJsonValue(JsonPasswordCrypto cryptoHandler, dynamic originalValue)
 {
     var valueToDecrypt = new EncryptedValue(originalValue.IV.Value, originalValue.Value.Value);
     var decryptedValue = cryptoHandler.Decrypt(valueToDecrypt);
     JObject valueToReplace = originalValue;
     valueToReplace.Replace(decryptedValue);
 }