class Ktct::Wangjinshe
Public Instance Methods
config()
click to toggle source
Calls superclass method
Ktct::Config#config
# File lib/ktct/wangjinshe.rb, line 38 def config super['wjs'] end
decrypt(data = nil)
click to toggle source
# File lib/ktct/wangjinshe.rb, line 20 def decrypt(data = nil) reset_key(config['client_private_key_path']) puts private_decrypt(Base64.strict_decode64((data || STDIN.read).gsub(/\n/, ''))) end
encrypt(data = nil)
click to toggle source
# File lib/ktct/wangjinshe.rb, line 14 def encrypt(data = nil) reset_key(config['server_public_key_path']) puts URI::encode_www_form_component(Base64.strict_encode64(public_encrypt(data || STDIN.read)).scan(/.{1,76}/).join("\n")) end
reset_key(key_file)
click to toggle source
# File lib/ktct/wangjinshe.rb, line 42 def reset_key(key_file) @key = OpenSSL::PKey::RSA.new(IO.read(File.expand_path(key_file))) end
sign(data = nil)
click to toggle source
# File lib/ktct/wangjinshe.rb, line 26 def sign(data = nil) reset_key(config['client_private_key_path']) puts URI::encode_www_form_component(Base64.strict_encode64(key.sign('sha1', data || STDIN.read)).scan(/.{1,76}/).join("\n")) end