Class: Universa::PBKDF2
- Inherits:
-
RemoteAdapter
- Object
- Delegator
- RemoteAdapter
- Universa::PBKDF2
- Defined in:
- lib/universa/contract.rb
Overview
Utiliy to generate keys of arbitrary length derived from passwords using PBKDF2 algorithm. Use PBKDF2.derive to produce keys from passwords in a realtively safe way (safety depends on the password strength)
Class Method Summary collapse
-
.derive(password, salt: "default_salt", rounds: 50000, hash: 'com.icodici.crypto.digest.Sha256', length: 32) ⇒ Binary
Derive a binary key from the string password using PBKDF2 algorithm.
Methods inherited from RemoteAdapter
#__getobj__, #__setobj__, #initialize, #inspect, invoke_static, remote_class, remote_class_name, remote_field, static_method, #to_s
Constructor Details
This class inherits a constructor from Universa::RemoteAdapter
Class Method Details
.derive(password, salt: "default_salt", rounds: 50000, hash: 'com.icodici.crypto.digest.Sha256', length: 32) ⇒ Binary
Derive a binary key from the string password using PBKDF2 algorithm.
32 33 34 35 |
# File 'lib/universa/contract.rb', line 32 def self.derive(password, salt: "default_salt", rounds: 50000, hash: 'com.icodici.crypto.digest.Sha256', length: 32) salt = salt.force_encoding('binary') if salt && salt.is_a?(String) invoke_static :derive, hash, password, salt, rounds, length end |