├── password-generator ├── README.md └── LICENSE /password-generator: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | hash() { 4 | local seed="${1}" 5 | local hash="$( 6 | tr -d '[:space:]' <<<"${seed}" | \ 7 | openssl md5 -binary | \ 8 | base64 | \ 9 | tr -d -c '[:alnum:]')" 10 | echo "${hash:0:8}" 11 | } 12 | 13 | while :; do 14 | read -sp 'Master password: ' password 15 | echo 16 | read -p "Password hash is $(hash "${password}"). Right? [Y/n] " yesno 17 | case "${yesno}" in 18 | [Nn]*) continue;; 19 | *) break;; 20 | esac 21 | done 22 | 23 | read -p 'Domain: ' domain 24 | domain="$(echo "${domain}" | tr '[A-Z]' '[a-z]')" 25 | seed="${password}@${domain}" 26 | 27 | password="$(hash ${seed})" 28 | if [ "${SSH_TTY+set}" == '' ]; then 29 | if which pbcopy >/dev/null 2>/dev/null; then 30 | echo -n "${password}" | pbcopy 31 | echo 'Password was copied to your clipboard.' 32 | exit 0 33 | fi 34 | fi 35 | 36 | echo "${password}" 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | password-generator is a command-line tool to use a different password for every site. 5 | 6 | * Web version - http://imoz.jp/password.html 7 | 8 | Usage 9 | ===== 10 | 11 | ```sh 12 | $ password-generator 13 | Master password: ← Type your master password here 14 | Password hash is 6nAeqHv2. Right? [Y/n] ← Press Enter key if it is correct. 15 | Domain: github.com ← Type a domain in lower case. 16 | Password was copied to your clipboard. 17 | ``` 18 | 19 | FAQ 20 | === 21 | 22 | What is Password Hash? 23 | ---------------------- 24 | 25 | Password hash is a fingerprint of your master password. 26 | Your master password is hidden in typing, so it is difficult to know if your password is correct, but the password hash should be a hint. 27 | 28 | How Password is Generated? 29 | -------------------------- 30 | 31 | The method to generate a password can be written in PHP like this: 32 | 33 | ```php 34 | base64_encode(hex2bin(md5(password + "@" + domain))) 35 | ``` 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Kentaro IMAJO 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------