Пример #1
0
        public static AsymmetricKeys GenerateAsymmetricKeys()
        {
            RSA myAlg = RSA.Create();

            AsymmetricKeys myKeys = new AsymmetricKeys();

            myKeys.PublicKey  = myAlg.ToXmlString(false);
            myKeys.PrivateKey = myAlg.ToXmlString(true);

            return(myKeys);
        }
Пример #2
0
        //Asymmetric (uses 2 keys), public to encrypt and private to decrypt
        //on registration both keys are generated and stored for each user in DB.
        //Asymmetrickeys, Asyencrypt and Asydec must all use same alg (RSA in this case.)

        //key generation
        public static AsymmetricKeys GenerateAsymmetricKeys()
        {
            RSA myAlg = RSA.Create();

            AsymmetricKeys myKeys = new AsymmetricKeys();

            myKeys.PublicKey  = myAlg.ToXmlString(false); //false to be a public key
            myKeys.PrivateKey = myAlg.ToXmlString(true);  //make true to be a private key

            return(myKeys);
        }