This repository has been archived on 2023-04-04. You can view files and clone it, but cannot push or open issues or pull requests.
webcrypto/test/crypto.ts

29 lines
724 B
TypeScript
Raw Permalink Normal View History

2019-01-25 10:43:13 +00:00
import assert from "assert";
import { Crypto } from "../src";
context("Crypto", () => {
const crypto = new Crypto();
context("getRandomValues", () => {
it("Uint8Array", () => {
const array = new Uint8Array(5);
const array2 = crypto.getRandomValues(array);
assert.notEqual(Buffer.from(array).toString("hex"), "0000000000");
assert.equal(Buffer.from(array2).equals(array), true);
});
it("Uint16Array", () => {
const array = new Uint16Array(5);
const array2 = crypto.getRandomValues(array);
assert.notEqual(Buffer.from(array).toString("hex"), "00000000000000000000");
assert.equal(Buffer.from(array2).equals(Buffer.from(array)), true);
});
});
});