コード例 #1
0
 public string Encrypt(string content)
 {
     if (content == null)
     {
         throw new ArgumentNullException(nameof(content));
     }
     using var aesObj = new AesGcmService(_key);
     return(aesObj.Encrypt(content));
 }
コード例 #2
0
        public EncryptedXmlInfo Encrypt(XElement plaintextElement)
        {
            if (plaintextElement == null)
            {
                throw new ArgumentNullException(nameof(plaintextElement));
            }

            using var aesObj = new AesGcmService(_key);

            var element = new XElement("encryptedKey",
                                       new XComment(" This key is encrypted with AES-256-GCM. "),
                                       new XElement("value",
                                                    aesObj.Encrypt(plaintextElement.ToString())));

            return(new EncryptedXmlInfo(element, typeof(AesGcmXmlDecryptor)));
        }