Initial project import for team collaboration.

Exclude local docs, MCP, and secrets via gitignore.

Made-with: Cursor
This commit is contained in:
taekyoungc
2026-03-25 12:05:33 +09:00
commit 4e557d4be1
153 changed files with 16198 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
/**
* PII(개인정보) 필드 암호화/복호화 헬퍼.
* encryption.key 가 .env에 설정된 경우에만 동작. 키가 없으면 평문 유지(기존 데이터 호환).
*
* 저장 형식: 암호화된 값은 "ENC:" + base64(암호문) 으로 저장. "ENC:" 없으면 평문(기존)으로 간주.
*/
if (! function_exists('pii_encrypt')) {
function pii_encrypt(?string $value): string
{
if ($value === null || $value === '') {
return '';
}
try {
$config = config('Encryption');
if ($config->key === '') {
return $value;
}
$encrypter = service('encrypter');
$encrypted = $encrypter->encrypt($value);
return 'ENC:' . base64_encode($encrypted);
} catch (Throwable) {
return $value;
}
}
}
if (! function_exists('pii_decrypt')) {
function pii_decrypt(?string $value): string
{
if ($value === null || $value === '') {
return '';
}
if (strpos($value, 'ENC:') !== 0) {
return $value;
}
try {
$config = config('Encryption');
if ($config->key === '') {
return $value;
}
$encrypter = service('encrypter');
$raw = base64_decode(substr($value, 4), true);
if ($raw === false) {
return $value;
}
return $encrypter->decrypt($raw);
} catch (Throwable) {
return $value;
}
}
}
/** 암호화 대상 개인정보 필드 (member 테이블) */
if (! defined('PII_ENCRYPTED_FIELDS')) {
define('PII_ENCRYPTED_FIELDS', ['mb_phone', 'mb_email']);
}