42 lines
727 B
Bash
42 lines
727 B
Bash
# vim: syn=sh ts=4 sts=4 sw=4 smartindent autoindent expandtab
|
|
|
|
symfony-make-apikey() {
|
|
if [ $# -gt 0 ]; then
|
|
local key_len="$1"
|
|
else
|
|
local key_len=60
|
|
fi
|
|
|
|
api_key=$(python << EOF
|
|
import random
|
|
import struct
|
|
import sys
|
|
import os
|
|
|
|
sys.stdin.reconfigure(encoding='utf-8')
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
|
|
seedstr = os.urandom(8)
|
|
|
|
seed = struct.unpack('@Q',seedstr)[0]
|
|
|
|
|
|
randchars='1234567890abcdefghijklmnopqrstABCDEFGHIJKLMNOPQRST*!+-_#$%&/([]){}?'
|
|
rstr=""
|
|
|
|
random.seed(seed)
|
|
for i in range($key_len):
|
|
rstr+=randchars[random.randrange(0,len(randchars),1)]
|
|
print(rstr)
|
|
|
|
EOF
|
|
)
|
|
|
|
if [ -f /dev/clipboard ]; then
|
|
echo -n "$api_key" > /dev/clipborad
|
|
fi
|
|
echo "$api_key"
|
|
}
|
|
|