Encrypt and decrypt your secrets with OpenSSL

preview_player
Показать описание
Some bash scripts I use to encrypt and decrypt secrets and passwords, using OpenSSL.

/usr/local/bin/f-dec

#!/bin/bash

if [ "$1" ]
then
openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 1000 -d -in $1
fi

/usr/local/bin/f-dec-xclip

#!/bin/bash

if [ "$1" ]
then
openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 1000 -d -in $1 | xargs echo -n | xclip
fi

/usr/local/bin/f-enc

#!/bin/bash

if [ "$1" ]
then
fi

/usr/local/bin/passgen

#!/bin/bash

lenght=12
maxucase=3
maxspecial=2

if [ "$1" ]
then
lenght=$1
fi

if [ "$2" ]
then
maxucase=$2
fi

if [ "$3" ]
then
maxspecial=$3
fi

if [ "$maxucase" -ge 1 ]
then
ucase=$(( 1 + RANDOM % ${maxucase} ))
else
ucase=0
fi

if [ "$maxspecial" -ge 1 ]
then
special=$(( 1 + RANDOM % ${maxspecial} ))
else
special=0
fi

choose() { echo ${1:RANDOM%${#1}:1} $RANDOM; }

password="$({
for i in $( seq 1 ${ucase} )
do
choose 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
done
for i in $( seq 1 ${special} )
do
choose '_!#%'
done
for i in $( seq 1 $((lenght - ucase - special)) )
do
choose '0123456789abcdefghijklmnopqrstuvwxyz'
done
} | sort -R | awk '{printf "%s",$1}')"

echo ${password}
Рекомендации по теме