* This method calculates the SHA-256 hash as HEX string of the given message. * This method uses the native hashing implementations of the SubtleCrypto interface which is supported by all browsers * that implement the Web Cryptography API specification and is based on: * https://developer.mozilla
(message)
| 322 | * @returns {Promise<string>} SHA-256 of the given message |
| 323 | */ |
| 324 | async function sha256(message) { |
| 325 | const msgUint8 = enc.encode(message); |
| 326 | const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); |
| 327 | const hashArray = Array.from(new Uint8Array(hashBuffer)); |
| 328 | |
| 329 | return hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Generates a non-secure random ASCII string of length {@code len}. |
no test coverage detected