bin/krypton in krypton-0.1.3 vs bin/krypton in krypton-0.1.4
- old
+ new
@@ -47,33 +47,39 @@
end.parse!(ARGV)
while (opt = ARGV.shift) do
case opt
+
+ # AESING
when 'encrypt'
- #puts Krypton::AESCrypt.encrypt(ARGV[ARGV.length - 2], ARGV[ARGV.length - 1], options[:outfile]) if options[:raw]
result = Base64.encode64(Krypton::AESCrypt.encrypt(ARGV[ARGV.length - 2], ARGV[ARGV.length - 1], options[:outfile]))
if options[:std]
puts result.strip
else
puts "#{ARGV[ARGV.length - 2] + ' => '}#{Paint[result.strip, '#2ecc71']}"
end
exit 0
when 'decrypt'
- #puts Krypton::AESCrypt.decrypt(ARGV[ARGV.length - 2], ARGV[ARGV.length - 1], options[:outfile]) if options[:raw]
result = Krypton::AESCrypt.decrypt(Base64.decode64(ARGV[ARGV.length - 2]), ARGV[ARGV.length - 1], options[:outfile])
if options[:std]
puts result.strip
else
puts "#{ARGV[ARGV.length - 2] + ' => '}#{Paint[result.strip, '#2ecc71']}"
end
exit 0
+
+ # HASHING
when 'hash'
- result = Krypton::SHA.hash(ARGV[ARGV.length - 1], options[:raw])
+
+ data = ARGV[ARGV.length - 1] || gets
+
+ result = Krypton::SHA.hash(data, options[:raw])
+
if options[:std]
puts result.strip
else
- puts "#{ARGV[ARGV.length - 1] + ' => '}#{Paint[result.strip, '#2ecc71']}"
+ puts "#{data + ' => '}#{Paint[result.strip, '#2ecc71']}"
end
exit 0
else
puts "#{opt} is not a valid action!"
exit 1