* Derives the checksum of a Buffer * @param {BufferSource} data * @returns the derived checksum
(data)
| 145 | * @returns the derived checksum |
| 146 | */ |
| 147 | async function checksum(data) { |
| 148 | const hashBuffer = await window.crypto.subtle.digest("SHA-256", data); |
| 149 | const hashArray = Array.from(new Uint8Array(hashBuffer)); |
| 150 | const hashHex = hashArray |
| 151 | .map((byte) => byte.toString(16).padStart(2, "0")) |
| 152 | .join(""); |
| 153 | return hashHex; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * |