diff --git a/package.json b/package.json index 870c252..8b5e03d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/sm2.js b/src/sm2.js index d5eb067..c14efb0 100644 --- a/src/sm2.js +++ b/src/sm2.js @@ -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() @@ -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) @@ -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()