Created
February 22, 2011 01:41
-
-
Save aishfenton/838076 to your computer and use it in GitHub Desktop.
Thinking behind possible way to encrypt info for vWork Customer Portal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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