Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created December 31, 2020 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreasvirkus/412c32772aec4d596d17ca64289b19ac to your computer and use it in GitHub Desktop.
Save andreasvirkus/412c32772aec4d596d17ca64289b19ac to your computer and use it in GitHub Desktop.
import crypto from 'crypto'
const generateChecksum = str =>
crypto
.createHash('sha256')
.update(str, 'utf8')
.digest('base64')
const script =
'if (localStorage.getItem("theme")) document.documentElement.dataset.theme = localStorage.getItem("theme")'
console.info(`sha256-${generateChecksum(script)}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment