Client-side changes for cryptographic login
This commit is contained in:
parent
3ceee1db4f
commit
3fb94984ec
5 changed files with 102 additions and 74 deletions
15
src/crypto.ts
Normal file
15
src/crypto.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
export const ENCRYPTION_TYPE = "SHA-256";
|
||||
|
||||
// Implemented according to https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
export const digestMessage = async (plaintext: string) => {
|
||||
const textEncoder = new TextEncoder();
|
||||
const digestArray = Array.from(
|
||||
new Uint8Array(
|
||||
await window.crypto.subtle.digest(
|
||||
ENCRYPTION_TYPE,
|
||||
textEncoder.encode(plaintext)
|
||||
)
|
||||
)
|
||||
)
|
||||
return digestArray.map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue