Ejemplo n.º 1
0
        /*
         * Cryptographically signs an entity.
         */
        static MultipartSigned Sign(
            MimeEntity entity,
            string armoredPrivateKey,
            string keyPassword)
        {
            var algo = DigestAlgorithm.Sha256;

            using (var ctx = new CreatePgpMimeContext {
                Password = keyPassword
            })
            {
                return(MultipartSigned.Create(
                           ctx,
                           PgpHelpers.GetSecretKeyFromAsciiArmored(armoredPrivateKey),
                           algo,
                           entity));
            }
        }
Ejemplo n.º 2
0
        /*
         * Cryptographically signs and encrypts an entity.
         */
        static MultipartEncrypted SignAndEncrypt(
            MimeEntity entity,
            Node encryptionNode,
            string armoredPrivateKey,
            string keyPassword)
        {
            var algo = DigestAlgorithm.Sha256;

            using (var ctx = new CreatePgpMimeContext {
                Password = keyPassword
            })
            {
                return(MultipartEncrypted.SignAndEncrypt(
                           ctx,
                           PgpHelpers.GetSecretKeyFromAsciiArmored(armoredPrivateKey),
                           algo,
                           GetEncryptionKeys(encryptionNode),
                           entity));
            }
        }