(a: Uint8Array, b: Uint8Array)
| 257 | |
| 258 | // XOR two buffers |
| 259 | function xor(a: Uint8Array, b: Uint8Array) { |
| 260 | const length = Math.max(a.length, b.length); |
| 261 | const res = []; |
| 262 | |
| 263 | for (let i = 0; i < length; i += 1) { |
| 264 | res.push(a[i] ^ b[i]); |
| 265 | } |
| 266 | |
| 267 | return ByteUtils.toBase64(ByteUtils.fromNumberArray(res)); |
| 268 | } |
| 269 | |
| 270 | async function H(method: CryptoMethod, text: Uint8Array): Promise<Uint8Array> { |
| 271 | const buffer = await crypto.subtle.digest(method === 'sha256' ? 'SHA-256' : 'SHA-1', text); |
no test coverage detected