INNER CODE UNIT · TypeScript
decrypt
vercel/server-components-notes-demo · libs/session.ts:57
return async function decrypt(data) {
const pwHash = await crypto.subtle.digest('SHA-256', pwUtf8)
const buffer = base64ToArrayBuffer(data)
const decryptKey = await crypto.subtle.importKey(
'raw',
pwHash,
algo,
false,
['decrypt']
)
const ptBuffer = await crypto.subtle.decrypt(algo, decryptKey, buffer)
const decryptedText = decode(ptBuffer)
return decryptedText
}
}
export function getSession(userCookie) {
const none = [null, null]