class Universa::SymmetricKey
A com.icodici.crypto.SymmetricKey
extension. As the key is immutable, caching is used to avoid unnecessary UMI
calls.
Public Class Methods
from_password(password, rounds, salt = nil)
click to toggle source
Derive key from password using PBKDF2
standard @param [String] password to derive key from @param [Object] rounds derivation rounds @param [Object] salt optional salt used to disallow detect password match by key match @return [SymmetricKey] instance
# File lib/universa/keys.rb, line 108 def self.from_password(password, rounds, salt = nil) salt.force_encoding(Encoding::BINARY) if salt invoke_static 'fromPassword', password, rounds, salt end
Public Instance Methods
eta_decrypt(plaintext)
click to toggle source
Decrypt data using EtA (HMAC)
# File lib/universa/keys.rb, line 136 def eta_decrypt(plaintext) __getobj__.eta_decrypt(plaintext.force_encoding('binary')) end
eta_encrypt(plaintext)
click to toggle source
Encrypt data using EtA (HMAC)
# File lib/universa/keys.rb, line 131 def eta_encrypt(plaintext) __getobj__.etaEncrypt(plaintext.force_encoding('binary')) end
key()
click to toggle source
Get the key as binary string @return [String] key bytes (binary string)
# File lib/universa/keys.rb, line 126 def key @key ||= getKey() end
size()
click to toggle source
@return [Integer] size in bytes
# File lib/universa/keys.rb, line 120 def size @size ||= getSize() end
size_in_bits()
click to toggle source
How many bits contains the key @return [Integer] size in bits
# File lib/universa/keys.rb, line 115 def size_in_bits @bit_strength ||= getBitStrength() end