INNER CODE UNIT · TypeScript

arrayBufferToBase64

vercel/server-components-notes-demo · libs/session.ts:28

function arrayBufferToBase64(buffer) {
  const bytes = new Uint8Array(buffer)
  // @ts-ignore
  const binary = String.fromCharCode(...bytes)
  return btoa(binary)
}

// Encrypt
export function createEncrypt() {
  return async function (data) {
    const pwHash = await crypto.subtle.digest('SHA-256', pwUtf8)
    const encryptKey = await crypto.subtle.importKey(
      'raw',
      pwHash,
      algo,
      false,
      ['encrypt']
    )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…