1. Abdelrahman Ghanem
  2. rgsum

Wiki

Clone wiki

rgsum / Home

Welcome

What about this project?

This project includes a simple ruby lib that can calculate md5,sha1,sha224,sha256,sha380,sha512.

Also there is a graphical user interface written in ruby and qt4 [rqsum], gtk [rgsum]

Examples

A simple example:

#!/bin/ruby
require 'sum'
sumlib=Sum.new
#set a file name
sumlib.filename="/home/any/file"
#set an algorithm
sumlib.algo='sha1'
#start sum
sumlib.sum
#print result
puts sumlib.result

Another one:

#!/bin/ruby
require 'sum'

sumlib=Sum.new
#set a file name ARGV[0]
sumlib.filename=$*[0]

#set an algorithm
sumlib.algo='md5'

#start sum, print progress
$stdout.sync=true
size=sumlib.size
sumlib.sum do |pos|
  percent=((pos.to_f/size)*100).round
  print "\rCalculating..#{percent}%"
end

#print result
puts "\nResult: "+sumlib.result

Updated