Beispiel #1
0
 public string ExtractMessage(DigitalSignatureResult signatureResult)
 {
     byte[] cipherTextBytes = Convert.FromBase64String(signatureResult.CipherText);
     byte[] signatureBytes  = Convert.FromBase64String(signatureResult.SignatureText);
     byte[] recomputedHash  = ComputeHashForMessage(cipherTextBytes);
     VerifySignature(recomputedHash, signatureBytes);
     byte[] plainTextBytes = GetReceiverCipher().Decrypt(cipherTextBytes, false);
     return(Encoding.UTF8.GetString(plainTextBytes));
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            Sender sender = new Sender();
            DigitalSignatureResult res = sender.BuildSignedMessage("Hello digital sig!");

            Console.WriteLine(res.CipherText);
            Console.WriteLine(res.SignatureText);

            String decryptedText = new Receiver().ExtractMessage(res);

            Console.WriteLine(decryptedText);

            Console.ReadKey();
        }