Class: HSMR::Component
Constant Summary
Constants included from HSMR
DOUBLE, SINGLE, TRIPLE, VERSION
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Instance Method Summary collapse
- #component ⇒ Object
-
#initialize(key = nil, length = DOUBLE) ⇒ Component
constructor
A new instance of Component.
Methods included from HSMR
cvv, decimalise, decrypt_pin, encrypt, encrypt_pin, #generate, ibm3624, #kcv, numeric?, #odd_parity?, #parity, pvv, #set_odd_parity, to_binary, to_hex, #to_s, #xor, xor, #xor!
Constructor Details
#initialize(key = nil, length = DOUBLE) ⇒ Component
Returns a new instance of Component.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/hsmr/component.rb', line 11 def initialize(key=nil, length=DOUBLE) ## Should check for odd parity if key.nil? key = generate(length) else key=key.gsub(/ /,'') #raise TypeError, "Component argument expected" unless other.is_a? Component end @key = key.unpack('a2'*(key.length/2)).map{|x| x.hex}.pack('c'*(key.length/2)) @length = @key.length @key = @key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/hsmr/component.rb', line 4 def key @key end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
5 6 7 |
# File 'lib/hsmr/component.rb', line 5 def length @length end |
Instance Method Details
#component ⇒ Object
7 8 9 |
# File 'lib/hsmr/component.rb', line 7 def component @key end |