Top Level Namespace
Defined Under Namespace
Classes: String
Instance Method Summary collapse
-
#rsa_key(bitsize_or_filename, password = nil) ⇒ Object
rsa key will either create a new RSA key if a bit size is supplied (multiples of 1024, 15 is supposed to be equivalent to AES-256) or the filename of an already created key.
Instance Method Details
#rsa_key(bitsize_or_filename, password = nil) ⇒ Object
rsa key will either create a new RSA key if a bit size is supplied (multiples of 1024, 15 is supposed to be equivalent to AES-256) or the filename of an already created key. If a password is given then the rsa file will be decrypted.
38 39 40 41 42 43 44 45 46 |
# File 'lib/string-encrypt.rb', line 38 def rsa_key(bitsize_or_filename,password = nil) if bitsize_or_filename.class.to_s == "String" && password == nil return OpenSSL::PKey::RSA.new(File.read(bitsize_or_filename)) elsif bitsize_or_filename.class.to_s == "String" && password != nil return OpenSSL::PKey::RSA.new(File.read(bitsize_or_filename).decrypt(password)) elsif bitsize_or_filename.class.to_s != "String" && password == nil then return OpenSSL::PKey::RSA.new(bitsize_or_filename) end end |