Module: Ronin::Support::Crypto::Key::Methods Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Common methods for Ronin::Support::Crypto::Key classes.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(key_class) ⇒ Object
private
Extends ClassMethods.
Instance Method Summary collapse
-
#save(path, encoding: :pem, cipher: 'aes-256-cbc', password: nil) ⇒ Object
private
Saves the key to the given path.
Class Method Details
.included(key_class) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extends ClassMethods.
39 40 41 |
# File 'lib/ronin/support/crypto/key/methods.rb', line 39 def self.included(key_class) key_class.extend ClassMethods end |
Instance Method Details
#save(path, encoding: :pem, cipher: 'aes-256-cbc', password: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Saves the key to the given path.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/ronin/support/crypto/key/methods.rb', line 145 def save(path, encoding: :pem, cipher: 'aes-256-cbc', password: nil) encoding_method = case encoding when :pem then method(:to_pem) when :der then method(:to_der) else raise(ArgumentError,"encoding: keyword argument (#{encoding.inspect}) must be either :pem or :der") end exported = if password cipher = OpenSSL::Cipher.new(cipher) encoding_method.call(cipher,password) else encoding_method.call end File.write(path,exported) end |