Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'digest'
- mySha1 = Digest::SHA1.new
- if (ARGV.index('-h')) && (ARGV[ARGV.index('-h')+1] != nil) # check if '-h' switch is in ARGV[] and the following index is non-null.
- if File.exist?(ARGV[ARGV.index('-h')+1]) #next check if that following index is an existing file.
- File.open(ARGV[ARGV.index('-h')+1]) do|file|
- myBuff = ''
- while not file.eof
- file.read(512, myBuff)
- mySha1.update(myBuff)
- end
- print mySha1
- end
- else
- print 'Invalid file specified'
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement