kanti/secrets
最新稳定版本:1.0.0
Composer 安装命令:
composer require kanti/secrets
包简介
Allows to commit encrypted Secrets
README 文档
README
This is a little library to allow to commit any Secret without exposing it to the public.
the secrets will be encrypted inside the code.
!!! the secrets will be stored as plaintext in a ksk-cache.json file on disk. (for performance reasons)
Installation
composer require kanti/secrets
Usage
in code
to encrypt a secret you can use the Secrets::convert() method.
use Kanti\Secrets\Secrets; # prerequisite: you need to have a .env file with a KSK_KEY set and It must be loaded in your code $databasePassword = Secrets::convert('topSecretPassword'); # after first run of this code the code will have change to: $databasePassword = Secrets::decrypt('7boUYdo8crSe1DsMDZbqG67vcvLxIOhEys1-9Rz-KUfzwX2k5ei5DhC2Wjt1qUzHK2N_pwqsrVO2VSEa');
use Kanti\Secrets\Secrets; # you can define the location of the ksk-cache.json file like this: Secrets::setCacheFile('/path/to/ksk-cache.json');
generate a secret
# this will generate a new secret and store it in the .env file (if not already present) ./vendor/bin/ksk # Outputs something like this: Key already set in /app/.env file KSK_KEY=ksk-yI1YRuVxsp1jJH7KcU3t2tignYmI2O_PLKqy2flBHzs1XBXudSLwf-lhryOV-qA4Rv0YchDb2jk ╔════════════════════ ═══ ══ ═ ═ ║ Found usage: ║ File: /app/sync.php:25 ║ value: "t34vctngh3840vngtc803m5b8t0gm2b4m29x4,nr94n," ║ // load dotenv ║ ║ dd([ ║ 'password2' => Secrets::decrypt('7boUYdo8crSe1DsMDZbqG67vcvLxIOhEys1-9Rz-KUfzwX2k5ei5DhC2Wjt1qUzHK2N_pwqsrVO2VSEa'), <--- "t34vctngh3840vngtc803m5b8t0gm2b4m29x4,nr94n," ║ 'top' => Secrets::decrypt('JSeg-Q6xMKJ52UUsLNQY766zNqThMeVRx4pmp03jIgD3wzbnoer-CA'), ║ 'password' => Secrets::decrypt('d0Fcuh2UcsMJe-j7ELUGKaq9NfflO_RH'), ║ ]); ╚════════════════════ ═══ ══ ═ ═ ╔════════════════════ ═══ ══ ═ ═ ║ Found usage: ║ File: /app/sync.php:26 ║ value: "top secret fake password" ║ ║ dd([ ║ 'password2' => Secrets::decrypt('7boUYdo8crSe1DsMDZbqG67vcvLxIOhEys1-9Rz-KUfzwX2k5ei5DhC2Wjt1qUzHK2N_pwqsrVO2VSEa'), ║ 'top' => Secrets::decrypt('JSeg-Q6xMKJ52UUsLNQY766zNqThMeVRx4pmp03jIgD3wzbnoer-CA'), <--- "top secret fake password" ║ 'password' => Secrets::decrypt('d0Fcuh2UcsMJe-j7ELUGKaq9NfflO_RH'), ║ ]); ║ ╚════════════════════ ═══ ══ ═ ═ ╔════════════════════ ═══ ══ ═ ═ ║ Found usage: ║ File: /app/sync.php:27 ║ value: "password" ║ dd([ ║ 'password2' => Secrets::decrypt('7boUYdo8crSe1DsMDZbqG67vcvLxIOhEys1-9Rz-KUfzwX2k5ei5DhC2Wjt1qUzHK2N_pwqsrVO2VSEa'), ║ 'top' => Secrets::decrypt('JSeg-Q6xMKJ52UUsLNQY766zNqThMeVRx4pmp03jIgD3wzbnoer-CA'), ║ 'password' => Secrets::decrypt('d0Fcuh2UcsMJe-j7ELUGKaq9NfflO_RH'), <--- "password" ║ ]); ║ ║ new SyncCommand(new Config(), new ConsoleLogger($output)); ╚════════════════════ ═══ ══ ═ ═
Linting
composer install grumphp run
Author
made with ❤️ by Kanti (Matthias Vogel)
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-02-12