예제 #1
0
파일: Iron.cs 프로젝트: vegah/Iron.NET
 private static IronDecryptResult CreateCryptoStreamAndDecryptResult(byte[] toDecrypt, IronKeyResult key, ICryptoTransform encryption, MemoryStream memoryStream)
 {
     using (var cryptoStream = new CryptoStream(memoryStream, encryption, CryptoStreamMode.Write))
     {
         cryptoStream.Write(toDecrypt, 0, toDecrypt.Length);
         cryptoStream.FlushFinalBlock();
         var encrypted = memoryStream.ToArray();
         return(new IronDecryptResult()
         {
             Key = key,
             DecryptedResult = System.Text.Encoding.UTF8.GetString(encrypted)
         });
     }
 }
예제 #2
0
파일: Iron.cs 프로젝트: vegah/Iron.NET
 private static IronDecryptResult DecryptWithCorrectDecryptionAlgorithm(byte[] toDecrypt, IronKeyResult key, ICryptoTransform encryption)
 {
     using (var memoryStream = new MemoryStream())
     {
         return(CreateCryptoStreamAndDecryptResult(toDecrypt, key, encryption, memoryStream));
     }
 }
예제 #3
0
파일: Iron.cs 프로젝트: vegah/Iron.NET
 private static IronEncryptResult WriteEncryptionToMemoryStream(string toEncrypt, IronKeyResult key, ICryptoTransform encryption, MemoryStream memoryStream)
 {
     using (var cryptoStream = new CryptoStream(memoryStream, encryption, CryptoStreamMode.Write))
     {
         return(WriteContentToCryptoStreamAndReturnEncryptedResult(toEncrypt, key, memoryStream, cryptoStream));
     }
 }
예제 #4
0
파일: Iron.cs 프로젝트: vegah/Iron.NET
        private static IronEncryptResult WriteContentToCryptoStreamAndReturnEncryptedResult(string toEncrypt, IronKeyResult key, MemoryStream memoryStream, CryptoStream cryptoStream)
        {
            var bytesToEncrypt = System.Text.Encoding.UTF8.GetBytes(toEncrypt);

            cryptoStream.Write(bytesToEncrypt, 0, bytesToEncrypt.Length);
            cryptoStream.FlushFinalBlock();
            var encrypted = memoryStream.ToArray();

            return(new IronEncryptResult()
            {
                Key = key,
                EncryptedResult = encrypted
            });
        }
예제 #5
0
파일: Iron.cs 프로젝트: vegah/Iron.NET
 private static IronEncryptResult EncryptWithCorrectEncryption(string toEncrypt, IronKeyResult key, ICryptoTransform encryption)
 {
     using (var memoryStream = new MemoryStream())
     {
         return(WriteEncryptionToMemoryStream(toEncrypt, key, encryption, memoryStream));
     }
 }