class Object

Constants

EXECUTER
FILENAME
KEY
TEST_CASE_FILE

Public Instance Methods

assert(expected_output, input) click to toggle source
# File bin/wingify_devfest_citd, line 22
def assert(expected_output, input)
        puts "\nRunning Test Case #{input}"
        start = Time.now.to_f
        result = expected_output.chomp == encrypt(`#{EXECUTER} #{FILENAME} #{input}`.chomp) ? 'PASS' : 'FAIL'
        time = Time.now.to_f - start
        puts "Result: #{result}, Time: #{time.round(2)}"
        return result == 'PASS' ? 1 : 0
end
encrypt(msg) click to toggle source
# File bin/wingify_devfest_citd, line 11
def encrypt(msg)
        return '' if msg == ''
        encrypter = OpenSSL::Cipher::AES.new(128, :CBC)
        encrypter.encrypt
        encrypter.pkcs5_keyivgen KEY, 'wingify1'
        # cipher.iv = OpenSSL::PKey::RSA.new('wingify')
        encrypted = encrypter.update msg
        encrypted << encrypter.final
        Base64.encode64(encrypted).encode('utf-8').gsub("\n", "").chomp
end