CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/backend/sha1.test.ts
Views: 923
1
import { sha1, uuidsha1 } from "./sha1";
2
3
const cocalc = "CoCalc";
4
const hash = "c898c97dca68742a5a6331f9fa0ca02483cbfd25";
5
const uuid = "c898c97d-ca68-4742-a5a6-331f9fa0ca02";
6
7
describe("compute some sha1 hashes", () => {
8
// This is mainly for long term backwards compatibility
9
it("SageMathCloud/string", () => {
10
expect(sha1("SageMathCloud")).toBe(
11
"31acd8ca91346abcf6a49d2b1d88333f439d57a6",
12
);
13
});
14
15
it("CoCalc/string", () => {
16
expect(sha1(cocalc)).toBe(hash);
17
});
18
19
it("CoCalc/Buffer", () => {
20
expect(sha1(Buffer.from(cocalc))).toBe(hash);
21
});
22
});
23
24
describe("UUIDs", () => {
25
it("CoCalc/string", () => {
26
expect(uuidsha1(cocalc)).toBe(uuid);
27
});
28
29
it("CoCalc/Buffer", () => {
30
expect(uuidsha1(Buffer.from(cocalc))).toBe(uuid);
31
});
32
});
33
34