private static void ForTempSave(string userName) { const int keySize = 2048; string publicAndPrivateKey; string publicKey; var root = new XElement("Root"); root.SetAttributeValue(Constants._ID, Guid.NewGuid().ToString()); AsymmetricEncryption.GenerateKeys(keySize, out publicKey, out publicAndPrivateKey); Console.WriteLine(@"public key:" + publicKey); Console.WriteLine(@"public & private key:" + publicAndPrivateKey); root.SetAttributeValue("PublicKey", publicKey); root.SetAttributeValue("PublicAndPrivateKey", publicAndPrivateKey); var productid = AsymmetricEncryption.GetProductId(); root.SetAttributeValue("ProductId", productid); //string userName = "******"; var text = userName + productid; var encrypted = AsymmetricEncryption.EncryptText(text, keySize, publicKey); Console.WriteLine(@"Encrypted: {0}", encrypted); //send encrypted data to service File.WriteAllText(userName + ".pem", @"UserName: "******" Public Key:" + publicKey + @" Public and Private Key: " + publicAndPrivateKey + @"Secrect: " + encrypted + @" For Test: " + productid); var decrypted = AsymmetricEncryption.DecryptText(encrypted, keySize, publicAndPrivateKey); //service person do below Console.WriteLine(@"Decrypted: {0}", decrypted); // Configuration.Set("UserName", userName); // Configuration.Set("PublicKey", publicKey); // Configuration.SaveSettings(); DBFactory.GetData().Save(root); Console.WriteLine(DBFactory.GetData().Read("a02cf4ad-ba0c-4c69-9f7c-e7d73a8fecad")); }