PHPackages                             martin3r/platform-core - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. martin3r/platform-core

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

martin3r/platform-core
======================

Plattform Core Package

01.7k↓33.3%PHP

Since Mar 24Pushed 2mo agoCompare

[ Source](https://github.com/martin3r-me/platforms-core)[ Packagist](https://packagist.org/packages/martin3r/platform-core)[ RSS](/packages/martin3r-platform-core/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Core – Feldverschlüsselung &amp; Hashing
========================================

[](#core--feldverschlüsselung--hashing)

Diese Bausteine stellen modulübergreifend sichere Feldverschlüsselung und Hashing bereit.

Überblick
---------

[](#überblick)

- Casts
    - `Platform\Core\Casts\EncryptedString` – verschlüsselt/entschlüsselt Strings transparent
    - `Platform\Core\Casts\EncryptedJson` – verschlüsselt/entschlüsselt JSON (Array)
- Trait
    - `Platform\Core\Traits\Encryptable` – richtet Casts ein und pflegt automatisch `_hash` beim Speichern
- Helper
    - `Platform\Core\Support\FieldHasher` – HMAC-SHA256 Hashing (mit optionalem Team-Salt), inkl. Key-Rotation
- Konfiguration
    - `config/security.php` – Schlüssel für Verschlüsselung/Hashing und Rotation

Verwendung in Modellen
----------------------

[](#verwendung-in-modellen)

1. Felder definieren (z. B. in einem Modul-Model):

```
use Platform\Core\Traits\Encryptable;

class CustomerSecret extends Model
{
    use Encryptable;

    protected array $encryptable = [
        'iban' => 'string',
        'api_token' => 'string',
        'meta' => 'json',
    ];
}
```

2. Migration im Modul:

```
Schema::table('customers', function (Blueprint $table) {
    $table->text('iban')->nullable();
    $table->char('iban_hash', 64)->nullable()->index();
    $table->text('api_token')->nullable();
    $table->char('api_token_hash', 64)->nullable()->index();
    $table->longText('meta')->nullable();
});
```

3. Suche über Hash statt Klartext:

```
use Platform\Core\Support\FieldHasher;

$teamSalt = (string) auth()->user()?->currentTeam?->id;
$hash = FieldHasher::hmacSha256($ibanImKlartext, $teamSalt);
$customer = CustomerSecret::where('iban_hash', $hash)->first();
```

Schlüsselrotation
-----------------

[](#schlüsselrotation)

- `.env`:
    - `HASH_KEY=stable-hash-key` (optional; Fallback ist `APP_KEY`)
    - `PREVIOUS_HASH_KEYS=oldHashKey1,oldHashKey2`
    - `PREVIOUS_ENCRYPTION_KEYS=oldEncKey1,oldEncKey2`
- Verhalten:
    - Casts versuchen Entschlüsselung mit aktuellem `APP_KEY`, dann mit `PREVIOUS_ENCRYPTION_KEYS`.
    - `FieldHasher::matchesAny($value, $teamSalt, config('security.previous_hash_keys'))` liefert Hashes für aktuelle und alte Keys (für Migrations-/Vergleichslogik).

Hinweise &amp; Best Practices
-----------------------------

[](#hinweise--best-practices)

- Verschlüsselte Felder als `text/longText` speichern.
- Für Indizes/Suche ausschließlich Hash-Spalten (`*_hash`) verwenden; niemals Klartext indizieren.
- Team-/Mandantensalt: Wenn möglich `team_id` als Salt nutzen, um Hashes teambezogen zu entkoppeln.
- Maskierung (UI/Logs): Bei Bedarf zusätzliche Helper ergänzen (z. B. IBAN-Maskierung).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance57

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/624263472b888cbddf2459047c1ab71dafd2a5875da576e3675b9c3584dad922?d=identicon)[martin3r](/maintainers/martin3r)

---

Top Contributors

[![martin3r-me](https://avatars.githubusercontent.com/u/187852765?v=4)](https://github.com/martin3r-me "martin3r-me (28 commits)")

### Embed Badge

![Health badge](/badges/martin3r-platform-core/health.svg)

```
[![Health](https://phpackages.com/badges/martin3r-platform-core/health.svg)](https://phpackages.com/packages/martin3r-platform-core)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
