SHARE
TWEET

Untitled

Ortund Jul 5th, 2016 (edited) 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// <summary>
  2. /// Uses CreateKey to generate a 10-character long password string
  3. /// </summary>
  4. /// <returns>Random string value eg. xX*tjoqOVw</returns>
  5. public static string CreatePasswordString()
  6. {
  7.     string Chars = @"~`!@#$%^&*()\/',.?;:|";
  8.     var RNG = new Random();
  9.  
  10.     // Select a character to insert into the password
  11.     string Character = new String(Enumerable.Repeat(Chars, 1).Select(s => s[RNG.Next(s.Length)]).ToArray());
  12.  
  13.     return CreateKey(9).Insert(RNG.Next(9), Character);
  14. }
  15.  
  16. /// <summary>
  17. /// Runs the specifed password through bcrypt hashing
  18. /// </summary>
  19. /// <param name="password"></param>
  20. /// <returns></returns>
  21. public static string CreatePassword(string password)
  22. {
  23.     byte[] PasswordBytes = Encoding.ASCII.GetBytes(password);
  24.  
  25.     // no need to generate a salt value since bcrypt does that all on its own
  26.     return Crypter.Blowfish.Crypt(PasswordBytes);
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top