Skip to content

Instantly share code, notes, and snippets.

@aishfenton
Created February 22, 2011 01:41
Show Gist options
  • Select an option

  • Save aishfenton/838076 to your computer and use it in GitHub Desktop.

Select an option

Save aishfenton/838076 to your computer and use it in GitHub Desktop.
Thinking behind possible way to encrypt info for vWork Customer Portal
require 'openssl'
require 'digest/sha1'
ENCRYPT_METHOD = "aes-256-cbc"
API_KEY = "YOUR_VWORKAPP_API_KEY"
# What you have to do
c = OpenSSL::Cipher::Cipher.new(ENCRYPT_METHOD)
c.encrypt
# your pass is what is used to encrypt/decrypt
c.key = Digest::SHA1.hexdigest(API_KEY)
e = c.update("USER_ID + JOB_ID")
e << c.final
puts "Encrypted text to send: #{e}\n"
# What we do
c = OpenSSL::Cipher::Cipher.new(ENCRYPT_METHOD)
c.decrypt
c.key = Digest::SHA1.hexdigest(API_KEY)
d = c.update(e)
d << c.final
puts "Decrypted result: #{d}\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment