Exemplo n.º 1
0
        public string GetPublicKey()
        {
            var keys = RSACryptor.CreateKeys(2048, KeyFormat.XML);

            //where store private key? put into redis ?

            return(keys[1]);
        }
Exemplo n.º 2
0
        public void CreatPrivateKeyTest()
        {
            var keys = RSACryptor.CreateKeys(2048, KeyFormat.XML);

            Assert.NotNull(keys);
            Assert.True(keys.Count == 2);

            var publicKey  = keys[0];
            var privateKey = keys[1];

            Assert.NotNull(publicKey);
            Assert.NotNull(privateKey);
            Assert.True(!publicKey.IsBase64());             // xml content is not base64 string

            keys       = RSACryptor.CreateKeys(2048, KeyFormat.Pkcs1);
            publicKey  = keys[0];
            privateKey = keys[1];
            Assert.True(publicKey.IsBase64() && privateKey.IsBase64());             // is base64

            keys       = RSACryptor.CreateKeys(2048, KeyFormat.Pkcs8);
            publicKey  = keys[0];
            privateKey = keys[1];
            Assert.True(publicKey.IsBase64() && privateKey.IsBase64());             // is base64
        }
Exemplo n.º 3
0
        private RSACryptor CreateCryptor()
        {
            var keys = RSACryptor.CreateKeys(2048, KeyFormat.Pkcs1);

            return(new RSACryptor(RSAType.RSA2, Encoding.UTF8, keys[0], keys[1]));
        }