Skip to content
Snippets Groups Projects
Commit 40e892f8 authored by yisding's avatar yisding Committed by Marcus Schiesser
Browse files

Oops adding back Alex's crypto changes

parent 23810253
Branches
Tags
No related merge requests found
import CryptoJS from "crypto-js"; import { createHash } from "node:crypto";
import path from "path"; import path from "path";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
...@@ -177,13 +177,13 @@ export class TextNode<T extends Metadata = Metadata> extends BaseNode<T> { ...@@ -177,13 +177,13 @@ export class TextNode<T extends Metadata = Metadata> extends BaseNode<T> {
* @returns * @returns
*/ */
generateHash() { generateHash() {
const hashFunction = CryptoJS.algo.SHA256.create(); const hashFunction = createHash("sha256");
hashFunction.update(`type=${this.getType()}`); hashFunction.update(`type=${this.getType()}`);
hashFunction.update( hashFunction.update(
`startCharIdx=${this.startCharIdx} endCharIdx=${this.endCharIdx}`, `startCharIdx=${this.startCharIdx} endCharIdx=${this.endCharIdx}`,
); );
hashFunction.update(this.getContent(MetadataMode.ALL)); hashFunction.update(this.getContent(MetadataMode.ALL));
return hashFunction.finalize().toString(CryptoJS.enc.Base64); return hashFunction.digest("base64");
} }
getType(): ObjectType { getType(): ObjectType {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment