Skip to content

Instantly share code, notes, and snippets.

@ayush--s
Created December 22, 2013 19:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayush--s/8087365 to your computer and use it in GitHub Desktop.
Save ayush--s/8087365 to your computer and use it in GitHub Desktop.

####All this because :

  • I need to have strong passwords everywhere
  • I don't want to use a single password everywhere
  • I can't remember all my passwords
  • I have productivity issues with LastPass & Keepass2

####Trade-Offs / Comparisons:

  • I happen to use my friends' computers heck lot, and using Lastpass/Keepass there is not always the best option
  • Lastpass seriously fucks up when you use two accounts in the same site, the integration there is more annoying than useful
  • I want to reproduce my password in every computer without downloading my full passwords file
  • each time I need a password, i have to open keepass which takes ~ 15 secs and 6-7 clicks. This script takes ~ 5 secs and 3 clicks on my Sublime Text
  • you need to remember a salt rather insted of a password which is essentialy the same thing
  • there is a simple script as opposed to bulky apps/extensions
  • *if you lose your script file that has your salt in it, you're doomed - don't blame me *- this is not such a big problem in lastpass/ definitely not in keepass
  • c'mon 4 lines of code can't beat full-fledged proven apps in features - Lastpass & specifically Keepass has tons of security features

###How to reproduce your passwords EVERYTIME :

  • stick to the same algo (MD5, SHA2,etc) everytime
  • make sure you don't forget your SALT

####Also there is no ranmodness in password generation - the output is always same for same inputs

id = 'ayush--s@github.com' # Set id eachtime
require 'digest/md5'
class PwdGen
def initialize(id, salt='your-salt-here') # set salt only once, which will be default unless you
@salt = salt # provide it as the second argument while creating object
@id = id
end
def gen()
symbols = ['!','@','#','$','%','^','&','*','(',')']
t = Digest::MD5.hexdigest( @salt.to_s + @id.to_s )
(t[0,7].upcase + symbols[ (@id.to_s.length)%10 ] + t[9,4])
end
end
pwd=PwdGen.new(id)
puts pwd.gen()
salt = 'your-salt-here'

pick a salt - a password that is constant throughout all your different actual passwords , ie, what you choose here should remain constant throughout

id = 'ayush--s@github.com'

your username - show your creativity here and use
anything as long as it has your username , the host site in it and you can remember what the pattern looks like. Right here it is :

user@site

now one way md5 hashing happens

t = Digest::MD5.hexdigest( salt+id )

The output is a 12-letter string containing a single symbol and a few numbers as well also, it satisfies the lowercase - uppercase requirement of most sites

puts (t[0,7].upcase + symbols[ (id.length)%10 ] + t[9,4])
@ayush--s
Copy link
Author

note: this was dumb. i went back to using lastpass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment