Advertisement
canid

sha1Me

Dec 31st, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.50 KB | None | 0 0
  1. require 'digest'
  2.  
  3. mySha1 = Digest::SHA1.new
  4.  
  5. if (ARGV.index('-h')) && (ARGV[ARGV.index('-h')+1] != nil) # check if '-h' switch is in ARGV[] and the following index is non-null.
  6.     if File.exist?(ARGV[ARGV.index('-h')+1]) #next check if that following index is an existing file.
  7.         File.open(ARGV[ARGV.index('-h')+1]) do|file|
  8.             myBuff = ''    
  9.             while not file.eof
  10.                 file.read(512, myBuff)
  11.                 mySha1.update(myBuff)
  12.             end
  13.         print mySha1
  14.         end
  15.     else
  16.         print 'Invalid file specified'
  17.     end
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement