First commit
This commit is contained in:
commit
d739b3d893
2 changed files with 99 additions and 0 deletions
43
README.md
Normal file
43
README.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
# YPassword
|
||||
|
||||
This is the YPassword command line utility.
|
||||
|
||||
YPassword is password management method.
|
||||
It helps you to use only very strong password everywhere.
|
||||
Each different for each website.
|
||||
Accent is made on portability.
|
||||
|
||||
To learn more about this method just visit:
|
||||
[ypassword.espozito.com](http://ypassword.espozito.com)
|
||||
|
||||
It needs you to create a ~/.password file, it should contains something
|
||||
similar to:
|
||||
|
||||
forrst.com yogsototh 10 b64 sha512
|
||||
freenode.net yogsototh 10 b64 sha512
|
||||
foursquare.com yann.esposito@gmail.com 10 b64 sha512 1
|
||||
twitter.com yogsototh 20 hex sha512
|
||||
|
||||
Columns:
|
||||
|
||||
1. URL of website
|
||||
2. Login
|
||||
3. Size of the password
|
||||
4. Output format b64 (recommended) or hex
|
||||
b64 is something like: `NzMzN2Q2ZWFhMDUxYWVlNTcxMTgwYzViM`
|
||||
hex is something like: `7337d6eaa051aee571180c5b356d40b4294e4c7242b6e3bc39fc700bab550540`
|
||||
5. Hash algorithm sha1 (not recommended), sha256, sha512 (recommended)
|
||||
6. An optional number, if you want to change your password for a specific website, just change this number.
|
||||
|
||||
Usage:
|
||||
|
||||
ypassword pattern
|
||||
|
||||
The application wait for you to type your main password each time you use it.
|
||||
|
||||
Example:
|
||||
|
||||
> ./ypassword twit
|
||||
twitter.com (yogsototh): 0018b7bd1cd0197e1ae14dfbc568b27b3a45
|
||||
|
||||
In the end you'll only have to copy/paste this password.
|
56
ypassword
Executable file
56
ypassword
Executable file
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
(($#<1)) && {
|
||||
print -- "usage: $0:t pattern"
|
||||
print -- " generate a password using the ypassword method"
|
||||
print -- " See http://ypassword.espozito.com for more informations"
|
||||
} >&2
|
||||
|
||||
param="$*"
|
||||
passfile="~/.passwd"
|
||||
cmd="awk '\$1 ~ /$param/ {print;}' < $passfile"
|
||||
nblignes=$( eval $cmd | wc -l)
|
||||
|
||||
function col {
|
||||
colnum=$1
|
||||
shift
|
||||
echo $* | awk "{print \$$colnum}"
|
||||
}
|
||||
|
||||
if ((nblignes<1)); then
|
||||
echo "entrée non existante"
|
||||
elif ((nblignes>1)); then
|
||||
echo "plusieur cas possibles : "
|
||||
eval $cmd | sort
|
||||
else
|
||||
line="$(eval $cmd)"
|
||||
site=$( col 1 $line )
|
||||
domainName=$( echo $site | sed 's/.*\.\([^.]*\.[^.]*\)$/\1/')
|
||||
loginName=$( col 2 $line )
|
||||
longueur=$( col 3 $line )
|
||||
base64=$( col 4 $line )
|
||||
hashalgo=$( col 5 $line )
|
||||
num=$( col 6 $line )
|
||||
echo "Enter your master password please"
|
||||
echo -n "$site ($loginName): "
|
||||
oldmodes=$(stty -g)
|
||||
stty -echo
|
||||
read password
|
||||
stty $oldmodes
|
||||
|
||||
case $hashalgo in
|
||||
sha1) hashcmd="sha1sum" ;;
|
||||
sha256) hashcmd="sha512sum" ;;
|
||||
sha512) hashcmd="sha512sum" ;;
|
||||
*) print -- "Unknown algorithm: $hashalgo" >&2
|
||||
exit 1
|
||||
esac
|
||||
|
||||
if [[ $base64 = "b64" ]]; then
|
||||
# make a hex2b64
|
||||
hashcmd="$hashcmd | cut -f1 -d\\ | xxd -r -p | base64 --wrap=88"
|
||||
fi
|
||||
|
||||
cmd='echo -n "'$password$num$domainName'" | '$hashcmd' | awk "{print substr(\$1,1,'$longueur');}"'
|
||||
eval $cmd
|
||||
fi
|
Loading…
Reference in a new issue