PHP | OpenSSL 암호화(openssl_encrypt, openssl_decrypt)
페이지 정보
작성일2016-09-05 14:45 조회10,796회관련링크
본문
- 목차 -
//PHP 5.2 이하 버젼 openssl 미지원시
openssl_encrypt
string openssl_encrypt ( string $data , string $method , string $password [, int $options = 0 [, string $iv = "" ]] )
openssl_decrypt
string openssl_decrypt ( string $data , string $method , string $password [, int $options = 0 [, string $iv = "" ]] )
예제 소스
$data = "가나다라마바사"; $crypt_pass = "abcdefghij123456"; // 16자리 $crypt_iv = "abcdefghij123456"; // 16자리 // 암호화 $endata = @openssl_encrypt($data , "aes-128-cbc", $crypt_pass, true, $crypt_iv); $endata = base64_encode($endata); echo "ENCODE DATA : " . $endata . "
"; // 복호화 $data = base64_decode($endata); $endata = @openssl_decrypt($data, "aes-128-cbc", $crypt_pass, true, $crypt_iv); echo "DECODE DATA : " . $endata . "
";
결과 출력
ENCODE DATA : ypNDtWwSkJqS5hSXiI8ctSstbfj37ral3T2EkHwgfzQ= DECODE DATA : 가나다라마바사
$method
- AES-128-CBC
- AES-128-CFB
- AES-128-CFB1
- AES-128-CFB8
- AES-128-ECB
- AES-128-OFB
- AES-192-CBC
- AES-192-CFB
- AES-192-CFB1
- AES-192-CFB8
- AES-192-ECB
- AES-192-OFB
- AES-256-CBC
- AES-256-CFB
- AES-256-CFB1
- AES-256-CFB8
- AES-256-ECB
- AES-256-OFB
- BF-CBC
- BF-CFB
- BF-ECB
- BF-OFB
- CAST5-CBC
- CAST5-CFB
- CAST5-ECB
- CAST5-OFB
- DES-CBC
- DES-CFB
- DES-CFB1
- DES-CFB8
- DES-ECB
- DES-EDE
- DES-EDE-CBC
- DES-EDE-CFB
- DES-EDE-OFB
- DES-EDE3
- DES-EDE3-CBC
- DES-EDE3-CFB
- DES-EDE3-OFB
- DES-OFB
- DESX-CBC
- IDEA-CBC
- IDEA-CFB
- IDEA-ECB
- IDEA-OFB
- RC2-40-CBC
- RC2-64-CBC
- RC2-CBC
- RC2-CFB
- RC2-ECB
- RC2-OFB
- RC4
- RC4-40
- aes-128-cbc
- aes-128-cfb
- aes-128-cfb1
- aes-128-cfb8
- aes-128-ecb
- aes-128-ofb
- aes-192-cbc
- aes-192-cfb
- aes-192-cfb1
- aes-192-cfb8
- aes-192-ecb
- aes-192-ofb
- aes-256-cbc
- aes-256-cfb
- aes-256-cfb1
- aes-256-cfb8
- aes-256-ecb
- aes-256-ofb
- bf-cbc
- bf-cfb
- bf-ecb
- bf-ofb
- cast5-cbc
- cast5-cfb
- cast5-ecb
- cast5-ofb
- des-cbc
- des-cfb
- des-cfb1
- des-cfb8
- des-ecb
- des-ede
- des-ede-cbc
- des-ede-cfb
- des-ede-ofb
- des-ede3
- des-ede3-cbc
- des-ede3-cfb
- des-ede3-ofb
- des-ofb
- desx-cbc
- idea-cbc
- idea-cfb
- idea-ecb
- idea-ofb
- rc2-40-cbc
- rc2-64-cbc
- rc2-cbc
- rc2-cfb
- rc2-ecb
- rc2-ofb
- rc4
- rc4-40
$password
- The password.
$options
- options is a bitwise disjunction of the flags OPENSSL_RAW_DATA and OPENSSL_ZERO_PADDING.
$iv
- A non-NULL Initialization Vector.
Developer 관련 글 보기
- PHP | (PHP/MySQL) password_hash / password / old_password 2022-03-02
- PHP | 텔레그램(telegram) 봇 API 응답 값 살펴보기 2019-10-01
- PHP | [PHP] 텔레그램 api로 push 받기(Webhook) 2019-10-01
- Server | PHP 7.3, 7.2, 7.1 on CentOS/RHEL 6.10 2019-06-24
- Server | 사설인증서 생성을 위한 OpenSSL (for Windows) 사용방법 2019-06-14
- Script | jquery live, bind, delegate 를 on 대체 2018-01-16
- HTML | ASCII Code 특수기호 모음 2016-12-10