canid

sha1Me-0.1

Dec 31st, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     myFile = ARGV[ARGV.index('-h')+1]
  7.     if File.exist?(myFile) # next check if that file exists.
  8.         File.open(myFile]) do|file|
  9.             myBuff = ''    
  10.             while not file.eof
  11.                 file.read(512, myBuff)
  12.                 mySha1.update(myBuff)
  13.             end
  14.         print mySha1
  15.         end
  16.     else
  17.         print 'Invalid file specified'
  18.     end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment