Class: BasecommSdk::TripleDesService
- Inherits:
-
Object
- Object
- BasecommSdk::TripleDesService
- Defined in:
- lib/basecomm_sdk/triple_des_service.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #decrypt(input) ⇒ Object
- #encrypt(input) ⇒ Object
-
#initialize(key) ⇒ TripleDesService
constructor
A new instance of TripleDesService.
Constructor Details
#initialize(key) ⇒ TripleDesService
Returns a new instance of TripleDesService.
7 8 9 |
# File 'lib/basecomm_sdk/triple_des_service.rb', line 7 def initialize(key) @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/basecomm_sdk/triple_des_service.rb', line 5 def key @key end |
Instance Method Details
#decrypt(input) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/basecomm_sdk/triple_des_service.rb', line 19 def decrypt(input) cipher.decrypt cipher_result = '' cipher_result << cipher.update([input].pack('H*')) cipher_result << cipher.final cipher_result end |
#encrypt(input) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/basecomm_sdk/triple_des_service.rb', line 11 def encrypt(input) cipher.encrypt cipher_result = '' cipher_result << cipher.update(input) cipher_result << cipher.final cipher_result.unpack('H*')[0] end |