Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 39 lines (27 sloc) 1.03 KB
#!/usr/bin/env ruby
# Progress OpenEdge Generate-PBE-KEY function in ruby.
# - Hardcoded for MD5, 4000 iterations, with a 32-byte key output.
require 'openssl'
require 'rbkb'
puts "Cleartext password:"
cleartext = gets.chomp
def generate_pbe_key(p)
pass = p
4000.times do
pass = OpenSSL::Digest::MD5.digest pass
end
return pass
end
P1 = generate_pbe_key cleartext
P2 = generate_pbe_key (P1+cleartext)
DK = P1 + P2
puts "\nMaster Key (base64 encoded):"
puts DK.b64
puts "\nMaster Key (hex):"
puts DK.hexify
# Sample password: SpiderLabs
# => 4f81a4b9910305b0017d44feb79002a5e5c6f1aba43780f90a98465d0704df9f
# Sample encryption of card, utilizes hex master key:
# echo "4111111111111111" | openssl aes-256-cbc -a -e -p -K '4f81a4b9910305b0017d44feb79002a5e5c6f1aba43780f90a98465d0704df9f' -iv ""
# Sample decryption of encrypted card value, utilizes hex master key:
# echo "fAXl4Kpfef6ie83qGM21oi9MJXGTpxBfAcmNcppkrqE=" | openssl aes-256-cbc -a -d -p -K '4f81a4b9910305b0017d44feb79002a5e5c6f1aba43780f90a98465d0704df9f' -iv ""