lib/ossl_cryptor/cryptor.rb
# generate cipher key and iv.
# @param [String] mode crypt mode.
# @param [String] pass password, if pass = nil, use OsslCryptor::Generator::DEFAULT_PASS
# @param [String] salt salt data. if salt = nil, use random salt.
# @param [String] hash use hash algorithm when key and iv generate. if key_iv_hash = nil, use OsslCryptor::Generator::DEFAULT_KEY_IV_HASH
# @return [Hash] key and iv hash.

generate cipher key and iv.
generate cipher key and iv .
def generate_key_iv(mode, pass=nil, salt=nil, hash=nil)
      salt = salt.nil? ? get_default_salt(mode) : salt
      key_iv_str = OpenSSL::PKCS5.pbkdf2_hmac(pass, salt, 2000, (@cipher.key_len + @cipher.iv_len), hash)
      key = key_iv_str[0, @cipher.key_len]
      iv = key_iv_str[@cipher.key_len, @cipher.iv_len]
      cipher_key_iv = { key: key, iv: iv }
      cipher_key_iv
    end
def generate_key_iv ( mode , pass = nil , salt = nil , hash = nil ) salt = salt . nil? ? get_default_salt ( mode ) : salt key_iv_str = OpenSSL :: PKCS5 . pbkdf2_hmac ( pass , salt , 2000 , ( @cipher . key_len + @cipher . iv_len ) , hash ) key = key_iv_str [ 0 , @cipher . key_len ] iv = key_iv_str [ @cipher . key_len , @cipher . iv_len ] cipher_key_iv = { key : key , iv : iv } cipher_key_iv end
generate cipher key and iv.
generate cipher key and iv .
key and iv hash.
key and iv hash .
Hash
mode
<not_specific>
pass
<not_specific>
salt
<not_specific>
hash
<not_specific>
<not_specific>
hash use hash algorithm when key and iv generate. if key_iv_hash = nil, use OsslCryptor::Generator::DEFAULT_KEY_IV_HASH
hash use hash algorithm when key and iv generate . if key_iv_hash = nil use OsslCryptor :: Generator :: DEFAULT_KEY_IV_HASH