Class: OpenPGP::S2K::Salted
Overview
Constant Summary
collapse
- IDENTIFIER =
0x01
Constants inherited
from OpenPGP::S2K
DEFAULT
Instance Attribute Summary collapse
Attributes inherited from OpenPGP::S2K
#algorithm, #passphrase
Class Method Summary
collapse
Instance Method Summary
collapse
#digest, #digest_input_with_preload, #identifier, identifier, #to_key, #to_s
Constructor Details
#initialize(passphrase = nil, options = {}, &block) ⇒ Salted
Returns a new instance of Salted.
104
105
106
107
108
|
# File 'lib/openpgp/s2k.rb', line 104
def initialize(passphrase = nil, options = {}, &block)
super(passphrase, options, &block)
@salt = Random.bytes(8) unless @salt
end
|
Instance Attribute Details
#salt ⇒ Object
Returns the value of attribute salt.
102
103
104
|
# File 'lib/openpgp/s2k.rb', line 102
def salt
@salt
end
|
Class Method Details
.parse(input) ⇒ Object
98
99
100
|
# File 'lib/openpgp/s2k.rb', line 98
def self.parse(input)
self.new(nil, :algorithm => input.read_byte, :salt => input.read_bytes(8))
end
|
Instance Method Details
119
120
121
|
# File 'lib/openpgp/s2k.rb', line 119
def digest_input
salt.to_s[0, 8] << passphrase
end
|
#to_hash ⇒ Object
115
116
117
|
# File 'lib/openpgp/s2k.rb', line 115
def to_hash
super.merge({:salt => salt})
end
|
#write(buffer) ⇒ Object
110
111
112
113
|
# File 'lib/openpgp/s2k.rb', line 110
def write(buffer)
super(buffer)
buffer.write_bytes(salt)
end
|