Set of files and scripts for Embedded Lab 1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

17 lines
487 B

  1. #!/bin/sh -
  2. user="$1"
  3. . $(dirname $0)/settings.conf
  4. umask 077
  5. key="$(LC_ALL=C tr -c -d 'a-z0-9' < /dev/random | dd bs=1 count=50 2>/dev/null)"
  6. python3.8 -c 'import hashlib; import sqlite3; import sys; db = sqlite3.connect(sys.argv[1]); db.execute("insert into apikeys (user, key) values (?, ?)", (sys.argv[2], hashlib.blake2s(sys.argv[3].encode()).hexdigest())); db.commit(); db.close()' "$db_file" "$1" "$key"
  7. #echo "$1 $key" >> "$apikeyfile"
  8. echo "Your API key is: $key"
  9. exit 0