Example #1
0
        private void btnSign_Click(object sender, EventArgs e)
        {
            byte[] buffer = new byte[] { 0x00, 0x00, 0x00 };

            RSACryptoServiceProvider csp = RSASignatures.ReadRSAPrivateKeyPem("private.pem");
            string signature             = RSASignatures.Sign(buffer, csp);

            buffer = new byte[] { 0x00, 0x00, 0x01 };

            RSACryptoServiceProvider cspDec = RSASignatures.ReadRSAPublicKeyPem("public.pem");
            bool a = RSASignatures.Verify(buffer, signature, cspDec);
        }
Example #2
0
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            RSACryptoServiceProvider cspDec = RSASignatures.ReadRSAPublicKeyPem("public.pem");
            string text_to_sig = "PASSWORD";

            byte[] buffer = Encoding.UTF8.GetBytes(text_to_sig);

            byte[] encripted = cspDec.Encrypt(buffer, false);
            Console.WriteLine(Convert.ToBase64String(encripted));

            RSACryptoServiceProvider csp = RSASignatures.ReadRSAPrivateKeyPem("private.pem");

            byte[] dec    = csp.Decrypt(encripted, false);
            string decstr = Encoding.UTF8.GetString(dec);

            Console.WriteLine(decstr);
        }