Skip to content

Commit

Permalink
supplement comments
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored May 8, 2024
1 parent e6dbb92 commit 4b07625
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gmsm-sm2js",
"version": "0.7.1",
"version": "0.7.2",
"description": "Pure Javascript implementation of the SM2/SM3/SM4 functions based on jsrsasign",
"keywords": [
"sm2",
Expand Down
14 changes: 14 additions & 0 deletions src/sm2.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ class MessageDigest {
}
}

/**
* Finalizes the hash computation.
* @returns {Uint8Array} The digest of type Uint8Array
*/
digestRaw () {
if (useNodeSM3) {
const h = this.md.digest()
Expand All @@ -412,6 +416,11 @@ class MessageDigest {
}
}

/**
* Updates this hasher with a data and finalizes the hash computation.
* @param {string|Uint8Array} data the data to be appended
* @returns {string} The hex string of the digest
*/
digest (data) {
if (data) {
this.update(data)
Expand All @@ -427,6 +436,11 @@ class MessageDigest {
}
}

/**
* Updates this hasher with a hex string data and finalizes the hash computation.
* @param {string} hex the hex string data
* @returns {Uint8Array} The digest of type Uint8Array
*/
digestHex (hex) {
this.updateHex(hex)
return this.digest()
Expand Down

0 comments on commit 4b07625

Please sign in to comment.