// ╔════╤════════════════════════════════════════════════════════╗ // ║ 4d │ M E T H O D S ( P U B L I C ) ║ // ╟────┴────────────────────────────────────────────────────────╢ // ║ N O N - S T A T I C & S T A T I C ║ // ╚═════════════════════════════════════════════════════════════╝ #region ═╣ M E T H O D S ( P U B L I C ) ╠═ /// <summary> /// Generates a unique key-pair for RSA-encryption. /// </summary> /// <returns>A Private/Public Key-Pair</returns> public static RSAKeyPair GenerateKeyPair() { RSAKeyPair keys = new RSAKeyPair(); using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider()) { keys.PublicKey = RSA.ToXmlString(false); keys.PrivateKey = RSA.ToXmlString(true); } return(keys); }
/// <summary> /// Sets the users user-data. /// </summary> /// <param name="pUsername">Users username</param> /// <param name="pPassword">Users password</param> /// <param name="pPublicKey">Users public-key</param> internal void SetUserData(string pUsername, string pPassword, string pPublicKey = null) { Username = pUsername; Password = pPassword; if (pPublicKey != null) { RSAKeyPair keys = new RSAKeyPair { PublicKey = pPublicKey, PrivateKey = null }; RSAKeys = keys; } }