Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Uses CreateKey to generate a 10-character long password string
- /// </summary>
- /// <returns>Random string value eg. xX*tjoqOVw</returns>
- public static string CreatePasswordString()
- {
- string Chars = @"~`!@#$%^&*()\/',.?;:|";
- var RNG = new Random();
- // Select a character to insert into the password
- string Character = new String(Enumerable.Repeat(Chars, 1).Select(s => s[RNG.Next(s.Length)]).ToArray());
- return CreateKey(9).Insert(RNG.Next(9), Character);
- }
- /// <summary>
- /// Runs the specifed password through bcrypt hashing
- /// </summary>
- /// <param name="password"></param>
- /// <returns></returns>
- public static string CreatePassword(string password)
- {
- byte[] PasswordBytes = Encoding.ASCII.GetBytes(password);
- // no need to generate a salt value since bcrypt does that all on its own
- return Crypter.Blowfish.Crypt(PasswordBytes);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement