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.
2019-01-25 10:43:13 +00:00
|
|
|
import assert from "assert";
|
2020-03-23 08:04:24 +00:00
|
|
|
import { WebcryptoTest } from "@peculiar/webcrypto-test";
|
2019-01-25 10:43:13 +00:00
|
|
|
import { Crypto } from "../src";
|
|
|
|
|
2020-03-23 08:04:24 +00:00
|
|
|
const crypto = new Crypto();
|
|
|
|
|
|
|
|
WebcryptoTest.check(crypto as any, {});
|
2019-01-25 10:43:13 +00:00
|
|
|
context("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);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|