echo "data-to-encrypt" | ./encrypt.rb | pbcopy -
Last active
November 17, 2015 01:06
-
-
Save silasb/5badd65981a00de7125c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'openssl' | |
require 'base64' | |
public_key_file = 'public.pem' | |
string = ARGF.read | |
public_key = OpenSSL::PKey::RSA.new(File.read(public_key_file)) | |
encrypted_string = Base64.encode64(public_key.public_encrypt(string)) | |
print encrypted_string.split("\n").join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment