Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Data hashing mechanism

Michał B edited this page Jul 26, 2018 · 2 revisions

Salt generation and password hashing

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.


Password verification

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.


Other data hashing

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.


Verify other data

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.