Skip to content

Commit

Permalink
use sha1
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Nov 16, 2024
1 parent f77f2b7 commit d227507
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions client/src/playground/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ export async function initPlayIframe(
JSON.stringify(editorContent)
);
const sp = new URLSearchParams([["state", state]]);

const url = new URL(iframe.src);
url.host = `${
const host = `${
PLAYGROUND_BASE_HOST.startsWith("localhost") ? "" : `${hash}.`
}${PLAYGROUND_BASE_HOST}`;
const url = new URL(iframe.src);
url.host = host;
url.search = sp.toString();
iframe.src = url.href;

Expand All @@ -87,7 +87,7 @@ export async function compressAndBase64Encode(inputString: string) {
).arrayBuffer();

const compressed = await compressedStream;
const hashBuffer = await window.crypto.subtle.digest("SHA-256", compressed);
const hashBuffer = await window.crypto.subtle.digest("SHA-1", compressed);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hash = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
const state = bytesToBase64(compressed);
Expand Down
2 changes: 1 addition & 1 deletion libs/play/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export async function decompressFromBase64(base64String) {
return { state: null, hash: null };
}
const bytes = Buffer.from(base64String, "base64");
const hashBuffer = await crypto.subtle.digest("SHA-256", bytes);
const hashBuffer = await crypto.subtle.digest("SHA-1", bytes);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hash = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");

Expand Down

0 comments on commit d227507

Please sign in to comment.