BCrypt.Net.BCrypt.HashPassword C# (CSharp) Method

HashPassword() public static method

Hash a password using the OpenBSD bcrypt scheme and a salt generated by .
public static HashPassword ( string input ) : string
input string The password to hash.
return string
        public static string HashPassword(string input)
        {
            return HashPassword(input, GenerateSalt());
        }

Same methods

BCrypt::HashPassword ( string input, int workFactor ) : string
BCrypt::HashPassword ( string input, string salt ) : string

Usage Example

Beispiel #1
0
        public async Task <User> RegisterAsync(string username, string password, string firstName, string lastName, string role)
        {
            var user = await _dataContext.Users.SingleOrDefaultAsync(u => u.Username == username);

            if (user != null)
            {
                throw new LogicException("Пользователь с указанным именем уже существует");
            }

            user = new User(username, BC.HashPassword(password), firstName, lastName, role);

            _dataContext.Users.Add(user);
            await _dataContext.SaveChangesAsync();

            GenerateToken(user);
            return(user.WithoutPassword());
        }
All Usage Examples Of BCrypt.Net.BCrypt::HashPassword