-
Notifications
You must be signed in to change notification settings - Fork 11
Common Security
string MD5(string target)Produces 128-bit hash value of the string. PHP-compliant. The security of the MD5 hash function is severely compromised. It is not recommended for password hashing and provided only for backward compatibility.
string Sha1(string target)Produces 160-bit hash value of the string. The most widely used hashing algorithm. It is not recommended to use it for hashing now.
string Sha256(string target)Produces 256-bit hash value of the string. The variant of SHA-2. It provides good security for password hashing.
string Sha384(string target)Produces 384-bit hash value of the string. The variant of SHA-2. It provides good security for password hashing.
string Sha512(string target)Produces 512-bit hash value of the string. The variant of SHA-2. It provides very good security for password hashing.
byte[] Pbkdf2Sha1(string target, int numOfIterations);
byte[] Pbkdf2Sha1(string target, byte[] salt, int numOfIterations);Returns PBKDF2 compatible hash by using a pseudo-random number generator based on HMACSHA1. The default number of iterations is 10000.
string Hash(string target, HashMethods method)Hash string with the selected hash method. The string will contain a method name that was used for hashing. Possible methods are Md5, Sha1, Sha256, Sha384, Sha512, Pbkdf2Sha1.
bool CheckHash(string target, string hashedStringToCheck)Compares target string with hashed string.
uint Crc32(byte[] target, uint polynomial, uint seedCrc)Returns CRC-32 checksum. By default uses IEEE polynomial. Possible polynomials to use:
-
Crc32Ieee(default) Crc32CastagnoliCrc32Koopman
ulong Crc64(byte[] target, ulong polynomial, ulong seedCrc)Returns the CRC-64 checksum of data using the polynomial. The default implementation uses ISO polynomial. Possible polynomials to use:
-
Crc64IsoPolynomial(default) Crc64EcmaPolynomial
string ConvertBytesToString(byte[] bytes)Convert an array of bytes to string representation. Replace dashes with empty strings.
byte[] ConvertStringToBytes(string target)Convert string that contains hex representation of bytes to bytes array.