본문 바로가기

Language/PHP

PHP AES 암호화 (Cipher)

반응형
string openssl_encrypt ( string $data , string $method , string $password [, int $options = 0 [, string $iv = "" ]] )

string openssl_decrypt ( string $data , string $method , string $password [, int $options = 0 [, string $iv = "" ]] )

$data = 파일이나 텍스트같은 데이터

$method = 암호화 메소드 

$password = 암호화키

$option = OPENSSL_RAW_DATA(1 or true) OPENSSL_ZERO_PADDING(0 or false)

$iv = cbc를 사용할때 첫번째 암호화 블럭

$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 . "<br>";

// 복호화
$data = base64_decode($endata);
$endata = @openssl_decrypt($data, "aes-128-cbc", $crypt_pass, true, $crypt_iv);
echo "DECODE DATA : " . $endata . "<br>";

 

$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
반응형

'Language > PHP' 카테고리의 다른 글

phpstrom xdebug install 환경(centos7, php5.6, phpstorm)  (0) 2020.04.25
phpstorm remote(centos7) xdebug 설정  (0) 2020.03.22