Class: OAK::Key
- Inherits:
-
Object
- Object
- OAK::Key
- Defined in:
- lib/oak.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key) ⇒ Key
constructor
specifically a binary string of 32 bytes (256 bits), randomly-generated and kept very, very secret.
- #inspect ⇒ Object
Constructor Details
#initialize(key) ⇒ Key
specifically a binary string of 32 bytes (256 bits), randomly-generated and kept very, very secret.
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/oak.rb', line 78 def initialize(key) if !key.is_a?(String) raise ArgumentError, "bad non-String key: ELIDED" end rk_size = OAK.random_key.size if key.size != rk_size raise ArgumentError, "bad key ELIDED, length not #{rk_size}" end @key = key.dup.freeze # happy :) end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
89 90 91 |
# File 'lib/oak.rb', line 89 def key @key end |
Instance Method Details
#inspect ⇒ Object
91 92 93 94 95 96 |
# File 'lib/oak.rb', line 91 def inspect # # Avoid exposing the key in casual logs or console session. # to_s[0..-2] + " @key=ELIDED>" end |