Created
September 10, 2022 15:28
-
-
Save vikramacharya/7eb57a4fea591b5d2b145b8d861aa77a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const createSigningString = async (message: string, created?: string, expires?: string) => { | |
if (!created) created = Math.floor(new Date().getTime() / 1000).toString(); | |
if (!expires) expires = (parseInt(created) + (1 * 60 * 60)).toString(); | |
await _sodium.ready; | |
const sodium = _sodium; | |
const digest = sodium.crypto_generichash(64, sodium.from_string(message)); | |
const digest_base64 = sodium.to_base64(digest, base64_variants.ORIGINAL); | |
const signing_string = | |
`(created): ${created} | |
(expires): ${expires} | |
digest: BLAKE-512=${digest_base64}` | |
return { signing_string, expires, created } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment