# API Key Generator Service

## Overview
Generates cryptographically secure API keys with `face_` prefix.

## Features
- ✅ Cryptographically secure (uses `Str::random()`)
- ✅ Prefixed with `face_`
- ✅ Minimum 40 characters (45 total with prefix)
- ✅ Unique validation against clients table
- ✅ Auto-retry on collision

## Usage

### Automatic (Model)
```php
use App\Models\Client;

// API key auto-generated on creation
$client = Client::create(['name' => 'Acme Corp']);
// $client->api_key = "face_3ErGGS8g3Cc5DX70MAADCK1IAn3xBljLVSITPdOE"
```

### Manual (Service)
```php
use App\Services\ApiKeyGenerator;

$generator = app(ApiKeyGenerator::class);
$apiKey = $generator->generate();
// "face_3ErGGS8g3Cc5DX70MAADCK1IAn3xBljLVSITPdOE"
```

### Dependency Injection
```php
use App\Services\ApiKeyGenerator;

class ClientController extends Controller
{
    public function __construct(
        private ApiKeyGenerator $keyGenerator
    ) {}
    
    public function regenerateKey(Client $client)
    {
        $client->update([
            'api_key' => $this->keyGenerator->generate()
        ]);
    }
}
```

## Key Format
- Prefix: `face_`
- Random part: 40 characters (alphanumeric)
- Total length: 45 characters
- Example: `face_3ErGGS8g3Cc5DX70MAADCK1IAn3xBljLVSITPdOE`
