Пример #1
0
        public void EncryptDecrypt_R4096_JSON_Test()
        {
            var key       = RSAEncryptionProvider.CreateKey(RSAKeySizeTypes.R4096, RSAKeyTypes.JSON);
            var signature = RSAEncryptionProvider.Encrypt("image", key.PublicKey, keyType: RSAKeyTypes.JSON);
            var origin    = RSAEncryptionProvider.Decrypt(signature, key.PrivateKey, keyType: RSAKeyTypes.JSON);

            Assert.Equal("image", origin);
        }
Пример #2
0
        public void EncryptDecrypt_R1024_XML_Test()
        {
            var key       = RSAEncryptionProvider.CreateKey(RSAKeySizeTypes.R1024);
            var signature = RSAEncryptionProvider.Encrypt("image", key.PublicKey);
            var origin    = RSAEncryptionProvider.Decrypt(signature, key.PrivateKey);

            Assert.Equal("image", origin);
        }
Пример #3
0
        public void Test_Encrypt()
        {
            var key         = RSAEncryptionProvider.CreateKey();
            var source      = "装逼打脸2018";
            var cliphertext = RSAEncryptionProvider.Encrypt(source, key.PublickKey, outType: OutType.Hex);
            var plaintext   = RSAEncryptionProvider.Decrypt(cliphertext, key.PrivateKey, outType: OutType.Hex);
            var signData    = RSAEncryptionProvider.SignData(source, key.PrivateKey);
            var verifyData  = RSAEncryptionProvider.VerifyData(source, signData, key.PublickKey);

            Output.WriteLine("密文:\n" + cliphertext);
            Output.WriteLine("明文:\n" + plaintext);
            Output.WriteLine("签名:\n" + signData);
            Output.WriteLine("验签:\n" + verifyData);
        }