class String

Public Instance Methods

apiotics_decrypt(key) click to toggle source
# 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) click to toggle source
# 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