Skip to content

Instantly share code, notes, and snippets.

@romanbsd
Created March 4, 2024 14:15
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 romanbsd/23637ae2d82b28ad42138f2134fbcd59 to your computer and use it in GitHub Desktop.
Save romanbsd/23637ae2d82b28ad42138f2134fbcd59 to your computer and use it in GitHub Desktop.
def sha512_base64(string)
# Compute SHA-512 digest in binary form
digest = OpenSSL::Digest::SHA512.digest(string)
# Encode the binary digest in base64
base64_encoded = Base64.strict_encode64(digest)
"sha512-#{base64_encoded}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment