Files
cunkebao_v3/Moncter/config/encryption.php
2026-01-05 10:16:20 +08:00

61 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* 加密配置
*
* 用于身份证等敏感数据的加密和哈希
*/
return [
// AES 加密配置
'aes' => [
// 加密密钥32字节256位
// 注意:生产环境应使用环境变量或密钥管理服务,不要硬编码
// 使用 getenv() 获取环境变量,如果不存在则使用默认值
// 默认密钥至少32字符实际使用时会被 SHA256 哈希处理)
'key' => getenv('ENCRYPTION_AES_KEY') ?: 'your-32-byte-secret-key-here-12345678',
// 加密方法
'cipher' => 'AES-256-CBC',
// IV 长度(字节)
'iv_length' => 16,
],
// 哈希配置
'hash' => [
// 哈希算法(用于身份证哈希)
'algorithm' => 'sha256',
// 是否使用盐值(可选,增强安全性)
'use_salt' => true,
// 盐值(如果启用)
// 使用 getenv() 获取环境变量,如果不存在则使用默认值
'salt' => getenv('ENCRYPTION_HASH_SALT') ?: 'your-hash-salt-here',
],
// 脱敏配置
'masking' => [
// 身份证脱敏规则保留前6位和后4位中间用*替代
'id_card' => [
'prefix_length' => 6,
'suffix_length' => 4,
'mask_char' => '*',
],
// 手机号脱敏规则保留前3位和后4位中间用*替代
'phone' => [
'prefix_length' => 3,
'suffix_length' => 4,
'mask_char' => '*',
],
// 邮箱脱敏规则:保留@前的前2位和@后的域名
'email' => [
'prefix_length' => 2,
'mask_char' => '*',
],
],
];