src/snac/server/database/SQL.php
/**
     * Save User Key
     *
     * Save the given API key with provided label for the given user.  This method will
     * also have Postgres auto-generate an expiration time and unique database ID for the
     * key.  The key is stored using PHP's built-in password hashing scheme, which is
     * cryptographically secure; the key is unrecoverable from the database since this method
     * is a one-way hash.
     *
     * @param int $appUserID The numeric ID for the user
     * @param string $key The clear-text key to save (encrypted)
     * @param string $label The label for the key (stored in clear text)
     *
     * @return string[] All data for the inserted key as an associative array (includes expires and generated time)
     */
Save User Key
Save the given API key with provided label for the given user.  This method will
also have Postgres auto-generate an expiration time and unique database ID for the
key.  The key is stored using PHP's built-in password hashing scheme, which is
cryptographically secure; the key is unrecoverable from the database since this method
is a one-way hash.

@param int $appUserID The numeric ID for the user
@param string $key The clear-text key to save (encrypted)
@param string $label The label for the key (stored in clear text)

@return string[] All data for the inserted key as an associative array (includes expires and generated time)
Save User Key Save the given API key with provided label for the given user . This method will also have Postgres auto - generate an expiration time and unique database ID for the key . The key is stored using PHP ' s built - in password hashing scheme which is cryptographically secure ; the key is unrecoverable from the database since this method is a one - way hash . @param int $appUserID The numeric ID for the user @param string $key The clear - text key to save ( encrypted ) @param string $label The label for the key ( stored in clear text ) @return string [] All data for the inserted key as an associative array ( includes expires and generated time )
public function saveUserKey($appUserID, $key, $label)
    {
        $encrypt = password_hash($key, PASSWORD_DEFAULT);
        if ($encrypt === false)
            return null;
        $result = $this->sdb->query("insert into api_keys (uid, label, key) values ($1, $2, $3)
                                        returning *;", [$appUserID, $label, $encrypt]);
        $all = array();
        while($row = $this->sdb->fetchrow($result))
        {
            $all = $row;
        }
        return $all;
    }
public function saveUserKey ( $ appUserID , $ key , $ label ) { $ encrypt = password_hash ( $ key , PASSWORD_DEFAULT ) ; if ( $ encrypt === false ) return null ; $ result = $ this -> sdb -> query ( " insert into api_keys (uid, label, key) values ($1, $2, $3)
                                        returning *; " , [ $ appUserID , $ label , $ encrypt ] ) ; $ all = array ( ) ; while ( $ row = $ this -> sdb -> fetchrow ( $ result ) ) { $ all = $ row ; } return $ all ; }
Save User Key
 Save the given API key with provided label for the given user.
Save User Key Save the given API key with provided label for the given user .
// encrypt the key in the database // Return only the data returned (one row);