require 'openssl' ALGORITHM = 'AES-256-CBC' puts 'Enter key to decrypt with (in hexadecimal):' hex_key = gets.chomp puts 'Enter message to decrypt (in hexadecimal):' hex_message = gets.chomp cipher = OpenSSL::Cipher.new(ALGORITHM) key = [hex_key].pack('H*') message = [hex_message].pack('H*') cipher.decrypt cipher.key = key message = cipher.update(message) message << cipher.final puts "Decrypted message: #{message}"