Skip to content

Instantly share code, notes, and snippets.

View half-ogre's full-sized avatar

Drew Miller half-ogre

View GitHub Profile
@half-ogre
half-ogre / hash.rb
Created January 9, 2011 19:48
Creating a hash in Ruby with a random salt using /dev/random
require 'base64'
require 'digest/sha2'
def create(text)
salt_bytes = random_salt
salted_hash_bytes = Digest::SHA256.digest(salt_bytes+text)
Base64::encode64(salt_bytes+salted_hash_bytes)
end
def verify(hash, text)
#!/bin/bash
# first run 'rails my-app' and 'cd my-app'
git init
touch .gitignore
echo -e "log/*.log\ntmp/**/*\ndoc/api\ndoc/app\ndb/*.sqlite3" >> .gitignore
touch log/.gitignore
touch tmp/.gitignore
touch public/stylesheets/.gitignore