Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
<?php
namespace HiEvents\Enterprise\BoxOffice\Services\Domain;
use Illuminate\Config\Repository;
use Illuminate\Contracts\Hashing\Hasher;
class BoxOfficePinService
{
public function __construct(
private readonly Hasher $hasher,
private readonly Repository $config,
) {}
public function generate(): string
{
return str_pad((string) random_int(0, 999999), 6, '0', STR_PAD_LEFT);
}
public function hash(string $pin): string
{
return $this->hasher->make($this->keyedPin($pin));
}
public function verify(string $pin, string $hash): bool
{
return $this->hasher->check($this->keyedPin($pin), $hash);
}
private function keyedPin(string $pin): string
{
return hash_hmac('sha256', $pin, (string) $this->config->get('app.key'));
}
}