Skip to content

Instantly share code, notes, and snippets.

@BillyParadise
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BillyParadise/291448b7ade1e664c85d to your computer and use it in GitHub Desktop.
Save BillyParadise/291448b7ade1e664c85d to your computer and use it in GitHub Desktop.
hash comparing
require 'digest'
rolls = rand(1..1) #small for testing!
raw = ""
rolls.times do
raw = raw + "A,B,C,"
end
raw = raw[0...-1]
eggs = raw.split(",").shuffle!.shuffle!.shuffle!
omlette = eggs.join
hashbrown = Digest::SHA256.hexdigest(omlette)
tomorrow = Time.now.strftime("%d/%m/%Y")
rolls = rolls *3
spew = File.open("sample.txt", "w")
spew.print "Preroll for " + tomorrow + "\n"
spew.print "Today's Rolls: " + rolls.to_s + "\n"
spew.puts omlette
spew.puts hashbrown
spew.close
require 'digest'
puts "Testing the file: sample.txt"
file = File.open("sample.txt", "r")
fileday = file.readline
filerolls= file.readline
omlette = file.readline
puts "Supplied Rolls:"
puts omlette
hashbrown = file.readline
puts "Supplied Hash:"
puts hashbrown
puts "Calculated Hash:"
wtf = Digest::SHA256.hexdigest(omlette).chomp
puts wtf
if wtf.equal? hashbrown
puts "MATCH"
else
puts "NO MATCH"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment