mirror of
https://github.com/myvesta/vesta
synced 2025-07-31 03:51:14 -07:00
Simple api key generator
This commit is contained in:
parent
608b9d740a
commit
95b77d8bff
1 changed files with 37 additions and 0 deletions
37
bin/v-generate-api-key
Normal file
37
bin/v-generate-api-key
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
# info: generate api key
|
||||
# options: none
|
||||
#
|
||||
# The function creates a key file in /usr/local/vesta/data/keys/
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
keygen()
|
||||
{
|
||||
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
|
||||
}
|
||||
KEYS='/usr/local/vesta/data/keys/'
|
||||
HASH=$(keygen)
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
if [[ -e ${KEYS}${HASH} ]] ; then
|
||||
while [[ -e ${KEYS}${HASH} ]] ; do
|
||||
HASH=$(keygen)
|
||||
done
|
||||
fi
|
||||
|
||||
touch ${KEYS}${HASH}
|
||||
echo ${HASH}
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue