Example #1
0
        public void GenerateKey()
        {
            RSAKey RSAKey = new RSAKey();

            publickey  = RSAKey.GetPublicKey();
            privateKey = RSAKey.GetPrivateKey();
        }
Example #2
0
        public static RSAKey GenerateKeys()
        {
            CryptographicKey key = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithmNames.RsaPkcs1).CreateKeyPair(2048);

            byte[] privateKey;
            byte[] publicKey;

            CryptographicBuffer.CopyToByteArray(key.Export(CryptographicPrivateKeyBlobType.Capi1PrivateKey), out privateKey);
            CryptographicBuffer.CopyToByteArray(key.ExportPublicKey(CryptographicPublicKeyBlobType.Capi1PublicKey), out publicKey);

            RSAKey RSAKey = new RSAKey();

            RSAKey.PrivateKey = privateKey;
            RSAKey.PublicKey  = publicKey;

            return(RSAKey);
        }