팝빌 알림톡 기능 추가

This commit is contained in:
chym1217
2025-09-04 12:32:31 +09:00
parent 37d0dcb48f
commit 66f6a75a10
99 changed files with 8876 additions and 260 deletions

View File

@ -0,0 +1,44 @@
<?php
class cryptor {
public function encrypt($key, $data) {
// 키 설정
$publickey = $this->keyInstance($key);
openssl_public_encrypt($data, $encrypted, $publickey, OPENSSL_PKCS1_OAEP_PADDING);
return base64_encode($encrypted);
}
public function keyInstance($publickey) {
// startline , endline 설정
$start_line = "-----BEGIN PUBLIC KEY-----";
$end_line = "-----END PUBLIC KEY-----";
// key 추출 (정규식)
$pattern = "/-+([a-zA-Z\s]*)-+([^-]*)-+([a-zA-Z\s]*)-+/";
if(preg_match($pattern, $publickey, $matches)) {
$splitKey = $matches[2];
$splitKey = preg_replace('/\s+/', '', $splitKey);
} else {
return null;
}
$key = "";
for($pos=1; $pos <= strlen($splitKey); $pos++) {
if($pos % 64 == 0) {
$key = $key . $splitKey[$pos-1] . "\n";
} else {
$key = $key . $splitKey[$pos-1];
}
}
// startline, endline 추가
$key = $start_line . "\n" . $key . "\n" . $end_line;
return $key;
}
}
?>