Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/apiotics/encrypt_decrypt.rb
Instance Method Summary collapse
Instance Method Details
#apiotics_decrypt(key) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/apiotics/encrypt_decrypt.rb', line 16 def apiotics_decrypt(key) cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').decrypt begin cipher.key = Digest::SHA1.hexdigest key rescue cipher.key = (Digest::SHA1.hexdigest key)[0..23] end s = [self].pack("H*").unpack("C*").pack("c*") cipher.update(s) + cipher.final end |
#apiotics_encrypt(key) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/apiotics/encrypt_decrypt.rb', line 4 def apiotics_encrypt(key) cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt begin cipher.key = Digest::SHA1.hexdigest key rescue cipher.key = (Digest::SHA1.hexdigest key)[0..23] end s = cipher.update(self) + cipher.final s.unpack('H*')[0].upcase end |