aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/crypto.test.js
blob: 2c784e4968224f3a00d96301d5e20404bc4f9800 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import {
  sha,
  MD5,
  MD4,
  SHA1,
  SHA256,
  SHA384,
  SHA512,
  SHA512_256,
  gc,
} from "bun";
import { it, expect, describe } from "bun:test";
import { readFileSync } from "fs";

describe("crypto", () => {
  for (let Hash of [MD5, MD4, SHA1, SHA256, SHA384, SHA512, SHA512_256]) {
    for (let input of [
      "hello world",
      "hello world".repeat(20).slice(),
      "",
      "a",
    ]) {
      describe(input, () => {
        gc(true);

        it(`${Hash.name} base64`, () => {
          gc(true);
          const result = new Hash();
          result.update(input);
          expect(typeof result.digest("base64")).toBe("string");
          gc(true);
        });

        it(`${Hash.name} hash base64`, () => {
          Hash.hash(input, "base64");
          gc(true);
        });

        it(`${Hash.name} hex`, () => {
          const result = new Hash();
          result.update(input);
          expect(typeof result.digest("hex")).toBe("string");
          gc(true);
        });

        it(`${Hash.name} hash hex`, () => {
          expect(typeof Hash.hash(input, "hex")).toBe("string");
          gc(true);
        });

        it(`${Hash.name} buffer`, () => {
          var buf = new Uint8Array(256);
          const result = new Hash();

          result.update(input);
          expect(result.digest(buf)).toBe(buf);
          expect(buf[0] != 0).toBe(true);
          gc(true);
        });

        it(`${Hash.name} buffer`, () => {
          var buf = new Uint8Array(256);

          expect(Hash.hash(input, buf) instanceof Uint8Array).toBe(true);
          gc(true);
        });
      });
    }
  }
});
/vercel/src/serverless/entrypoint.ts?h=@astrojs/vercel@6.0.0-beta.1&id=49aa215a01ee1c4805316c85bb0aea6cfbc25a31&follow=1'>Switch `app.render` signature (#9199)Gravatar Arsh 8-10/+80 2023-11-29Unflag view transitions form handling (#9225)Gravatar Nate Moore 2-27/+33 2023-11-29Ensure dev overlay x-ray highlight goes over the island (#9227)Gravatar Matthew Phillips 3-1/+23 2023-11-29Small polish to the overlay (#9214)Gravatar Erika 2-5/+14 2023-11-29chore: remove deprecated `matchNotFound` options (#9212)Gravatar Alexander Niebuhr 5-10/+12 2023-11-28[ci] release (beta) (#9211)astro@4.0.0-beta.1@astrojs/upgrade@0.1.0-beta.0Gravatar Houston (Bot) 36-68/+118 2023-11-28feat: implement overlay main screen redesign (#9118)Gravatar Erika 50-217/+3638 2023-11-27[ci] release (beta) (#9114)create-astro@4.5.2-beta.0astro@4.0.0-beta.0@astrojs/vue@4.0.0-beta.0@astrojs/vercel@6.0.0-beta.0@astrojs/tailwind@6.0.0-beta.0@astrojs/svelte@5.0.0-beta.0@astrojs/rss@4.0.0-beta.0@astrojs/react@3.0.7-beta.0@astrojs/node@7.0.0-beta.0@astrojs/mdx@2.0.0-beta.0@astrojs/markdown-remark@4.0.0-beta.0Gravatar Houston (Bot) 66-154/+330 2023-11-27Remove support for simple objects in endpoints (#9181)Gravatar Bjorn Lu 56-529/+206 2023-11-28Remove shiki lang path property support (#9196)Gravatar Bjorn Lu 7-427/+22 2023-11-28Remove deprecated features from Astro 3.0 (#9168)Gravatar Bjorn Lu 47-398/+95 2023-11-28Remove deprecated markdown-remark APIs (#9182)Gravatar Bjorn Lu 4-59/+7 2023-11-27[ci] release (#9180)astro@3.6.1Gravatar Houston (Bot) 32-65/+63 2023-11-24Remove vercel deprecated analytics option (#9184)Gravatar Bjorn Lu 3-30/+12 2023-11-24[ci] formatGravatar Guspan Tanadi 1-2/+1 2023-11-24style: highlight markdown Tip Note section CONTRIBUTING (#9123)Gravatar Guspan Tanadi 1-5/+7 2023-11-23fix scroll restoration issue on webKit browsers (#9186)Gravatar Martin Trapp 2-1/+7 2023-11-23fix(middleware): rename internal middleware id (#9173)Gravatar Arsh 2-1/+6 2023-11-23fix: Changelog formatting for 3.6.0 View Transition events (#9176)Gravatar Martin Trapp 1-3/+3 2023-11-22[ci] formatGravatar Eva Decker 1-3/+3 2023-11-22Fix View Transitions code block formatting (#9174)Gravatar Eva Decker 1-3/+3 2023-11-22Rename entryPoint to entrypoint (#9161)Gravatar Bjorn Lu 14-26/+38 2023-11-22Fix esbuild warning for local dev (#9160)Gravatar Bjorn Lu 1-1/+1 2023-11-22[ci] release (#9165)astro@3.6.0Gravatar Houston (Bot) 34-90/+83