Skip to content

Instantly share code, notes, and snippets.

@jeffdonthemic
Last active May 9, 2023 17:48
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 jeffdonthemic/4706139076dc368ce27c5709c2e6787a to your computer and use it in GitHub Desktop.
Save jeffdonthemic/4706139076dc368ce27c5709c2e6787a to your computer and use it in GitHub Desktop.
Ruby crypto sign/verify
require 'openssl'
require 'base64'
private_key = File.read("./salesforce_private.key")
public_key = File.read("./salesforce_public.key")
data = "reports50"
priv_key = OpenSSL::PKey::RSA.new(private_key)
signature = priv_key.sign_pss("RSA-SHA512", data, salt_length: :digest, mgf1_hash: "RSA-SHA512")
puts Base64.strict_encode64(signature)
# pub_key = priv_key.public_key
# puts pub_key.verify_pss("RSA-SHA512", signature, data, salt_length: :auto, mgf1_hash: "RSA-SHA512") # => true
@jeffdonthemic
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment