Chrisbjr\ApiGuard\Repositories\ApiKeyRepository::generateKey PHP Method

generateKey() public static method

A sure method to generate a unique API key
public static generateKey ( ) : string
return string
    public static function generateKey()
    {
        do {
            $salt = sha1(time() . mt_rand());
            $newKey = substr($salt, 0, 40);
        } while (self::keyExists($newKey));
        return $newKey;
    }