= 4 && $length <= 255 && preg_match('/^[\x20-\x7E]+$/D', $deviceId) === 1; } public function hash(string $deviceId): string { $key = (string) config('earn.device.hash_key'); if (strlen($key) < 32) { throw new RuntimeException('Earn device hashing is not configured.'); } return hash_hmac('sha256', $this->normalize($deviceId), $key); } public function preview(string $deviceId): string { $normalized = $this->normalize($deviceId); if (strlen($normalized) <= 10) { return substr($normalized, 0, 2).'••••'.substr($normalized, -2); } return substr($normalized, 0, 6).'…'.substr($normalized, -5); } }