예제 #1
0
        public static string Decrypt(PublicSecret secret, string key)
        {
            Secret internalSecret = new Secret() {
                IV = Convert.FromBase64String(secret.IV),
                Data = Convert.FromBase64String(secret.Data)
            };

            AESEncryption encryptor = new AESEncryption(key);
            return encryptor.Decrypt(internalSecret);
        }
예제 #2
0
        public static PublicSecret Encrypt(string plainText, string key)
        {
            AESEncryption encryptor = new AESEncryption(key);
            Secret secret= encryptor.Encrypt(plainText);

            PublicSecret result = new PublicSecret();
            result.IV = Convert.ToBase64String(secret.IV);
            result.Data = Convert.ToBase64String(secret.Data);

            return result;
        }
예제 #3
0
        public void TestMethod1()
        {
            const string sourceText = "This is a test, indeed.";
            const string encryptionKey = "12345abcde....";

            AESEncryption enc = new AESEncryption(encryptionKey);

            Secret result = enc.Encrypt(sourceText);

            string decResult = enc.Decrypt(result);

            Assert.AreEqual(sourceText, decResult);
        }