Created
September 19, 2012 03:53
-
-
Save scpike/3747590 to your computer and use it in GitHub Desktop.
generate at token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
token = SecureRandom.urlsafe_base64 | |
# Naive, but with ~64^16 possibilities conflicts aren't a worry yet | |
# > 5,000,000.times {x << SecureRandom.urlsafe_base64}; puts x.uniq.count | |
# 5000000 | |
while Checkin.where(:token => token).any? | |
token = SecureRandom.urlsafe_base64 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment