Module: Dolla::EncryptionTools
- Included in:
- Gateway
- Defined in:
- lib/dolla/encryption_tools.rb
Instance Method Summary collapse
- #build_digest(*ary) ⇒ Object
- #decimal_format(value) ⇒ Object
- #padding(key) ⇒ Object
- #rijndael_encrypt(value) ⇒ Object
Instance Method Details
#build_digest(*ary) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/dolla/encryption_tools.rb', line 6 def build_digest *ary sha1 = HMAC::SHA1.new Dolla.configuration.hmac_key sha1 << ary.join sha1.to_s end |
#decimal_format(value) ⇒ Object
25 26 27 |
# File 'lib/dolla/encryption_tools.rb', line 25 def decimal_format value sprintf "%0.2f", value end |
#padding(key) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/dolla/encryption_tools.rb', line 13 def padding(key) final_key = "\0" * 16 key.length.times { |i| final_key[i%16] ^= key[i] } final_key end |
#rijndael_encrypt(value) ⇒ Object
20 21 22 23 |
# File 'lib/dolla/encryption_tools.rb', line 20 def rijndael_encrypt( value ) rijndael = Crypt::Rijndael.new Base64.decode64(Dolla.configuration.rijndael_key), 128 Base64.encode64( rijndael.encrypt_block( padding value ) ).strip end |