Skip to content

Instantly share code, notes, and snippets.

View tstevens's full-sized avatar

Trevor Stevens tstevens

View GitHub Profile
@tstevens
tstevens / SHA1.rb
Created April 18, 2011 14:08
Implementation of SHA-1 Hash in pure ruby
#http://stackoverflow.com/questions/5940316/left-rotate-through-carry-in-ruby
class Integer
def lotate(n=1)
self << n | self >> (32 - n)
end
end
# FIPS 180-2 -- relevant section #'s below
# Pulls parts from Wiki pseudocode and http://ruby.janlelis.de/17-sha-256
class SHA1
--- config.guess.orig 2010-01-02 20:51:35.000000000 -0500
+++ config.guess 2010-01-02 20:52:19.000000000 -0500
@@ -1259,6 +1259,10 @@ EOF
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in
+ i386) eval $set_cc_for_build
+ if $CC_FOR_BUILD -E -dM -x c /dev/null | grep __LP64__>/dev/null 2>&1 ; then
+ UNAME_PROCESSOR=x86_64
+ fi ;;