Skip to content

Commit eab72fc

Browse files
committed
Add one-way hash functions
1 parent c37a1a2 commit eab72fc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/components/Auth/Apiker/utils.ts

+16
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,22 @@ export const randomHash_SHA1 = (): string => {
150150
return CryptoJS.SHA1(wordArray).toString(CryptoJS.enc.Hex);
151151
};
152152

153+
/**
154+
* Creates SHA256 hash
155+
*/
156+
export const stringHash = (content: string) => {
157+
const wordArray = CryptoJS.lib.WordArray.create(content);
158+
return CryptoJS.SHA256(wordArray).toString(CryptoJS.enc.Hex);
159+
};
160+
161+
/**
162+
* Creates a random SHA1 hash
163+
*/
164+
export const stringHash_SHA1 = (content): string => {
165+
const wordArray = CryptoJS.lib.WordArray.create(content);
166+
return CryptoJS.SHA1(wordArray).toString(CryptoJS.enc.Hex);
167+
};
168+
153169
/**
154170
* Generating a clientId
155171
* This value is returned to client and not stored

0 commit comments

Comments
 (0)