Пример #1
0
        public void EncryptDecrypt_R3072_JSON_Test()
        {
            var key = RSAEncryptionProvider.CreateKey(RSAKeySizeTypes.R3072, RSAKeyTypes.JSON);

#if NET451
            var signature = RSAEncryptionProvider.EncryptByPublicKey("image", key.PublicKey, true, keyType: RSAKeyTypes.JSON);
            var origin    = RSAEncryptionProvider.DecryptByPrivateKey(signature, key.PrivateKey, true, keyType: RSAKeyTypes.JSON);
#else
            var signature = RSAEncryptionProvider.EncryptByPublicKey("image", key.PublicKey, RSAEncryptionPadding.OaepSHA1, keyType: RSAKeyTypes.JSON);
            var origin    = RSAEncryptionProvider.DecryptByPrivateKey(signature, key.PrivateKey, RSAEncryptionPadding.OaepSHA1, keyType: RSAKeyTypes.JSON);
#endif
            Assert.Equal("image", origin);
        }
Пример #2
0
        public void EncryptDecrypt_R2048_XML_Test()
        {
            var key = RSAEncryptionProvider.CreateKey();

#if NET451
            var signature = RSAEncryptionProvider.EncryptByPublicKey("image", key.PublicKey, true);
            var origin    = RSAEncryptionProvider.DecryptByPrivateKey(signature, key.PrivateKey, true);
#else
            var signature = RSAEncryptionProvider.EncryptByPublicKey("image", key.PublicKey, RSAEncryptionPadding.OaepSHA1);
            var origin    = RSAEncryptionProvider.DecryptByPrivateKey(signature, key.PrivateKey, RSAEncryptionPadding.OaepSHA1);
#endif
            Assert.Equal("image", origin);
        }