Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. require_relative 'bundle/bundler/setup'
  2.  
  3. require 'openssl'
  4. require 'base64'
  5. require 'iron_worker'
  6.  
  7. KEY = "IRONWORKERDEMOKEY"
  8. ALGORITHM = 'AES-128-ECB'
  9.  
  10. def encryption(msg)
  11. begin
  12. cipher = OpenSSL::Cipher.new(ALGORITHM)
  13. cipher.encrypt()
  14. cipher.key = KEY
  15. crypt = cipher.update(msg) + cipher.final()
  16. crypt_string = (Base64.encode64(crypt))
  17. return crypt_string
  18. rescue Exception => exc
  19. puts "Failed to encrypt: #{exc.message}"
  20. end
  21. end
  22.  
  23. def decryption(msg)
  24. begin
  25. cipher = OpenSSL::Cipher.new(ALGORITHM)
  26. cipher.decrypt()
  27. cipher.key = KEY
  28. tempkey = Base64.decode64(msg)
  29. crypt = cipher.update(tempkey)
  30. crypt << cipher.final()
  31. return crypt
  32. rescue Exception => exc
  33. puts "Failed to decrypt: #{exc.message}"
  34. end
  35. end
  36.  
  37. payload = IronWorker.payload
  38. text = payload['text']
  39.  
  40. puts "Original Payload: #{text}"
  41. text_encrypted = encryption(text)
  42. puts "Encrypted payload: #{text_encrypted}"
  43. text_decrypted = decryption(text_encrypted)
  44. puts "Decrypted payload: #{text_decrypted}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement