2013-04-24 16:58:31 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
encpasswd() {
|
2024-06-28 12:28:56 +02:00
|
|
|
local password_clear=$1
|
|
|
|
local password_md5hash=$(openssl passwd -1 "$password_clear")
|
|
|
|
local password_sha1=$(echo -n "$password_clear" | openssl dgst -sha1)
|
2013-04-24 16:58:31 +02:00
|
|
|
echo "Password : $password_clear"
|
|
|
|
echo "MD5HASH : $password_md5hash"
|
2013-06-14 16:59:16 +02:00
|
|
|
echo "SHA1 : $password_sha1"
|
2013-04-24 16:58:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
genpasswd() {
|
2024-06-28 12:28:56 +02:00
|
|
|
local l=$1
|
|
|
|
[ "$l" == "" ] && l=12
|
|
|
|
local password_clear=$(tr -dc A-Za-z0-9_ </dev/urandom | head -c "${l}" | xargs)
|
|
|
|
local password_md5hash=$(openssl passwd -1 "$password_clear")
|
2024-01-27 19:24:35 +01:00
|
|
|
local password_sha1=$(echo -n "$password_clear" | openssl dgst -sha1)
|
|
|
|
local password_base64=$(echo -n "$password_clear" | base64)
|
2013-04-24 16:58:31 +02:00
|
|
|
echo "Password : $password_clear"
|
2024-01-27 19:24:35 +01:00
|
|
|
echo "Base64 : $password_base64"
|
2013-04-24 16:58:31 +02:00
|
|
|
echo "MD5HASH : $password_md5hash"
|
2013-06-14 16:59:16 +02:00
|
|
|
echo "SHA1 : $password_sha1"
|
2013-04-24 16:58:31 +02:00
|
|
|
}
|