-
Notifications
You must be signed in to change notification settings - Fork 0
Data hashing mechanism
This mechanism uses HMCASHA512 algorithm to hash password. It also generates salt. To do that you must use one from the DataHashManager class methods:
public void CalculatePasswordHash(string password, out byte[] passwordHash, out byte[] passwordSalt)
It takes password given by user, then returns salt and hashed password as out parameters.
To verify password you have to use method:
public bool VerifyPasswordHash(string password, byte[] passwordHash, byte[] passwordSalt)
It takes password given by user, hashed password and salt from database. If password taken from user and hashed with the same salt will be equal to the hash from database, then method returns true. Otherwise it returns false.
To hash data that you want to verify without any salt (because this method doesn't need salt) you should use this method:
public UInt64 CalculateDataHash(string data)
This one needs any data that is in the string type and returns hashed data as an unsigned long integer.
To verify data hashed via CalculateDataHash(string data)
you must use this method:
public bool VerifyDataHash(string data, UInt64 dataHash)
Similar to VerifyPasswordHash
, this one returns true when reproduced hash is equal to the one from database. Otherwise it returns false.