Beispiel #1
0
        private static void DigitalSignatures()
        {
            var document = Encoding.UTF8.GetBytes("Document to Sign");

            byte[] hashedDocument;

            hashedDocument = HashData.ComputeHashSha256(document);

            var digitalSignature = new DigitalSignature();

            digitalSignature.AssignNewKey();

            var signature = digitalSignature.SignData(hashedDocument);
            var verified  = digitalSignature.VerifySignature(hashedDocument, signature);

            Console.WriteLine("Digital Signature Demonstration in .NET");
            Console.WriteLine("---------------------------------------");
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("   Original Text = " +
                              Encoding.Default.GetString(document));

            Console.WriteLine();
            Console.WriteLine("   Digital Signature = " +
                              Convert.ToBase64String(signature));

            Console.WriteLine();

            Console.WriteLine(verified
                ? "The digital signature has been correctly verified."
                : "The digital signature has NOT been correctly verified.");
        }
Beispiel #2
0
 public Form1()
 {
     InitializeComponent();
     rsa.AssignNewKey();
 }