tapbuy/data-scrubber
最新稳定版本:0.7.1
Composer 安装命令:
composer require tapbuy/data-scrubber
包简介
A tool to help with scrubbing sensitive data
README 文档
README
PHP library for anonymizing sensitive data in objects and arrays.
Installation
composer require tapbuy/data-scrubber
Usage
use Tapbuy\DataScrubber\Anonymizer; $anonymizer = new Anonymizer('https://your-api-url.com/keys'); $data = [ 'name' => 'John Doe', 'email' => 'john@example.com', 'phonenumber' => [ 'ssn' => '123-45-6789' ] ]; $anonymized = $anonymizer->anonymizeObject($data);
API
Anonymizer Class
class Anonymizer { public function __construct(string $url); public function updateKeys(): void; public function anonymizeObject(object|array $data): object|array; }
Keys Class
class Keys { public function __construct(string $url); public function fetchKeys(): void; public function getKeys(): array; }
Keys Format
Your API endpoint must return:
{
"success": true,
"data": ["name", "email", "ssn", "numbers[]"]
}
Keys with [] suffix indicate array fields that should have all elements anonymized.
Anonymization Rules
-
Strings: Replaced with
*of same length"John Doe" → "********" -
Numbers: Random number of same length/type
12345 → 98765 123.45 → 987.65
-
Arrays: If key marked with [], all elements anonymized
'numbers' => [123, 456] → [789, 012]
CLI
Update keys via command line:
php bin/updateKeys.php https://your-api-url.com/keys
Directory Structure
data-scrubber/
├── src/
│ ├── Anonymizer.php
│ └── Keys.php
├── bin/
│ └── updateKeys.php
└── composer.json
统计信息
- 总下载量: 2.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2024-04-26