Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require_relative 'bundle/bundler/setup'
- require 'openssl'
- require 'base64'
- require 'iron_worker'
- KEY = "IRONWORKERDEMOKEY"
- ALGORITHM = 'AES-128-ECB'
- def encryption(msg)
- begin
- cipher = OpenSSL::Cipher.new(ALGORITHM)
- cipher.encrypt()
- cipher.key = KEY
- crypt = cipher.update(msg) + cipher.final()
- crypt_string = (Base64.encode64(crypt))
- return crypt_string
- rescue Exception => exc
- puts "Failed to encrypt: #{exc.message}"
- end
- end
- def decryption(msg)
- begin
- cipher = OpenSSL::Cipher.new(ALGORITHM)
- cipher.decrypt()
- cipher.key = KEY
- tempkey = Base64.decode64(msg)
- crypt = cipher.update(tempkey)
- crypt << cipher.final()
- return crypt
- rescue Exception => exc
- puts "Failed to decrypt: #{exc.message}"
- end
- end
- payload = IronWorker.payload
- text = payload['text']
- puts "Original Payload: #{text}"
- text_encrypted = encryption(text)
- puts "Encrypted payload: #{text_encrypted}"
- text_decrypted = decryption(text_encrypted)
- puts "Decrypted payload: #{text_decrypted}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement