| 12345678910111213141516171819202122232425262728 |
- <?php
- function upro_encrypt($plainText, $password)
- {
- $password = substr(hash('sha256', $password, true), 0, 32);
- // Initial Vector(IV)는 128 bit(16 byte)입니다.
- $iv = chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0);
- // 암호화
- return base64_encode(openssl_encrypt($plainText, 'aes-256-cbc', $password, OPENSSL_RAW_DATA, $iv));
- }
- function upro_decrypt($encrypted, $password)
- {
- $password = substr(hash('sha256', $password, true), 0, 32);
- // Initial Vector(IV)는 128 bit(16 byte)입니다.
- $iv = chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0);
- // 복호화
- return openssl_decrypt(base64_decode($encrypted), 'aes-256-cbc', $password, OPENSSL_RAW_DATA, $iv);
- }
- ?>
|