class ActiveSupport::KeyGenerator

Overview

A simple wrapper around OpenSSL's PBKDF2 implementation.

KeyGenerator derives keys from a secret using PBKDF2-HMAC. Different salts can be used to derive multiple independent keys from the same secret.

This is a minimal implementation compatible with ActiveSupport::KeyGenerator from Rails: https://api.rubyonrails.org/classes/ActiveSupport/KeyGenerator.html

It is primarily used for compatibility with ActiveStorage::Blob and ActiveRecord::Encryption.

Defined in:

active_support/key_generator.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.instance : self #

def self.new(secret : String, hash_digest : OpenSSL::Algorithm = OpenSSL::Algorithm::SHA256, iterations : Int32 = 2 ** 16) #

Class Method Detail

def self.instance=(key_generator : self) #

Instance Method Detail

def generate_key(salt, key_size = 64) #