diff options
| author | 2023-04-19 17:30:39 +0800 | |
|---|---|---|
| committer | 2023-04-19 17:30:39 +0800 | |
| commit | 3adc965dd09490b7efa1cce9f09b0a3b30970277 (patch) | |
| tree | f813abb07d7b003984aa74e3154752b6ffc3ccd5 /envshare/pkg/encryption.test.ts | |
| parent | c7c9ca6f0c8eddf6d34cd40779f3b2d9463f3a46 (diff) | |
| download | HydroRoll-3adc965dd09490b7efa1cce9f09b0a3b30970277.tar.gz HydroRoll-3adc965dd09490b7efa1cce9f09b0a3b30970277.zip | |
✨优化文档
Diffstat (limited to 'envshare/pkg/encryption.test.ts')
| -rw-r--r-- | envshare/pkg/encryption.test.ts | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/envshare/pkg/encryption.test.ts b/envshare/pkg/encryption.test.ts deleted file mode 100644 index 5d4cf15..0000000 --- a/envshare/pkg/encryption.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { describe, it, expect, beforeAll } from "@jest/globals"; -import { decrypt, encrypt } from "./encryption"; -import crypto from "node:crypto"; -import { toBase58 } from "../util/base58"; - -beforeAll(() => { - global.crypto = crypto.webcrypto; -}); -describe("aes", () => { - it("encrypts and decrypts correctly", async () => { - for (let i = 0; i < 500; i++) { - const buf = new Uint8Array(Math.ceil(Math.random() * 10 * i)); - crypto.getRandomValues(buf); - - const text = toBase58(buf); - - const { encrypted, key, iv } = await encrypt(text); - - const decrypted = await decrypt(toBase58(encrypted), key, toBase58(iv), 2); - - expect(decrypted).toEqual(text); - } - }, 30_000); -}); |
