암호화 업그레이드

문서

변경된 사항

  • PHP 7.2부터 deprecated된 MCrypt에 대한 지원이 중단되었습니다.

업그레이드 가이드

  1. 설정에서 $config['encryption_key'] = 'abc123';application/config/config.php에서 app/Config/Encryption.phppublic $key = 'abc123';으로 이동되었습니다.

  2. CI3의 암호화로 암호화된 데이터를 복호화해야 하는 경우, 호환성을 유지하도록 설정을 구성하십시오. CI3과의 호환성을 유지하기 위한 설정를 참조하십시오.

  3. 암호화 라이브러리를 사용한 모든 곳에서 $this->load->library('encryption');$encrypter = service('encrypter');로 교체하고, 다음 코드 예제와 같이 암호화 및 복호화 메서드를 변경해야 합니다.

코드 예제

CodeIgniter 버전 3.x

<?php

$this->load->library('encryption');

$plain_text = 'This is a plain-text message!';
$ciphertext = $this->encryption->encrypt($plain_text);

// Outputs: This is a plain-text message!
echo $this->encryption->decrypt($ciphertext);

CodeIgniter 버전 4.x

<?php

$encrypter = service('encrypter');

$plainText  = 'This is a plain-text message!';
$ciphertext = $encrypter->encrypt($plainText);

// Outputs: This is a plain-text message!
echo $encrypter->decrypt($ciphertext);