TShockAPI.DB.User.HashPassword C# (CSharp) Method

HashPassword() protected method

Returns a hashed string for a given string based on the config file's hash algo
protected HashPassword ( byte bytes ) : string
bytes byte bytes to hash
return string
        protected string HashPassword(byte[] bytes)
        {
            if (bytes == null)
                throw new NullReferenceException("bytes");
            Func<HashAlgorithm> func;
            if (!HashTypes.TryGetValue(TShock.Config.HashAlgorithm.ToLower(), out func))
                throw new NotSupportedException("Hashing algorithm {0} is not supported".SFormat(TShock.Config.HashAlgorithm.ToLower()));

            using (var hash = func())
            {
                var ret = hash.ComputeHash(bytes);
                return ret.Aggregate("", (s, b) => s + b.ToString("X2"));
            }
        }

Same methods

User::HashPassword ( string password ) : string