Javascript Hasher
(Created page with "Hasher handling object. ==Constructor== * '''new Hasher(type)''' Parameters:<br> '''type''': Hash type, one of 'md5', 'sha1', 'sha256' ==Methods== * '''update(data,isHex)''...") |
|||
Line 1: | Line 1: | ||
Hasher handling object. | Hasher handling object. | ||
− | ==Constructor== | + | == Constructor == |
* '''new Hasher(type)''' | * '''new Hasher(type)''' | ||
Line 7: | Line 7: | ||
'''type''': Hash type, one of 'md5', 'sha1', 'sha256' | '''type''': Hash type, one of 'md5', 'sha1', 'sha256' | ||
− | ==Methods== | + | |
+ | == Static methods == | ||
+ | |||
+ | * '''fips186prf(seed,len[,sep])''' | ||
+ | NIST FIPS 186-2 change notice 1 Pseudo Random Function.<br> | ||
+ | Uses a b=160 bits SHA1 based G(t,c) function with no XSEEDj<br> | ||
+ | |||
+ | Parameters:<br> | ||
+ | '''seed''': String, hexified data to use as RNG seed, must be 1 to 64 octets long<br> | ||
+ | '''len''': Numeric. Desired output length in octets, must be 1 to 512<br> | ||
+ | '''sep''': String, first character only. Desired separator for output string nibbles (bytes)<br> | ||
+ | Return:<br> | ||
+ | String (hexified output) on success, ''null'' on failure | ||
+ | |||
+ | |||
+ | |||
+ | == Methods == | ||
* '''update(data,isHex)''' | * '''update(data,isHex)''' | ||
Update (append data to) hasher. | Update (append data to) hasher. |
Latest revision as of 15:09, 6 September 2024
Hasher handling object.
[edit] Constructor
- new Hasher(type)
Parameters:
type: Hash type, one of 'md5', 'sha1', 'sha256'
[edit] Static methods
- fips186prf(seed,len[,sep])
NIST FIPS 186-2 change notice 1 Pseudo Random Function.
Uses a b=160 bits SHA1 based G(t,c) function with no XSEEDj
Parameters:
seed: String, hexified data to use as RNG seed, must be 1 to 64 octets long
len: Numeric. Desired output length in octets, must be 1 to 512
sep: String, first character only. Desired separator for output string nibbles (bytes)
Return:
String (hexified output) on success, null on failure
[edit] Methods
- update(data,isHex)
Update (append data to) hasher.
Parameters:
data: Data to append
isHex: Optional parameter. A boolean TRUE will indicate data is a hexified buffer
Return:
TRUE on success, FALSE on failure (data is invalid, the hasher is already finalized or any other error)
- hmac(key,msg,isHex)
Compute a message authentication code with this hash. Finalize the hash if not already done.
Parameters:
key: Secret key
msg: Message to authenticate
isHex: Optional parameter. A boolean TRUE will indicate the key and msg are hexified buffers
Return:
TRUE on success, FALSE on failure (input data is invalid or any other error)
- hexDigest()
Retrieve the standard hexadecimal representation of the hash. Finalize the hash if not already done.
Return:
Hexified string, empty if an error occurred.
- clear()
Clear the hasher and prepare it for reuse.
- finalize()
Finalize the hasher, make result ready. Subsequent updates will fail.
- hashLength()
Retrieve the raw binary hash length.
Return:
Length of the hash in octets
- hmacBlockSize()
Retrieve the size of the block used for HMAC calculations.
Return:
HMAC block size in octets