crypto#webcrypto JavaScript Examples

The following examples show how to use crypto#webcrypto. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: crypto.spec.js    From kit with MIT License 6 votes vote down vote up
inputs.forEach((input) => {
	test(input, async () => {
		// @ts-expect-error typescript what are you doing you lunatic
		const expected_bytes = await webcrypto.subtle.digest(
			'SHA-256',
			new TextEncoder().encode(input)
		);
		const expected = Buffer.from(expected_bytes).toString('base64');

		const actual = sha256(input);
		assert.equal(actual, expected);
	});
});
Example #2
Source File: csp.spec.js    From kit with MIT License 5 votes vote down vote up
// @ts-expect-error
globalThis.crypto = webcrypto;