다음과 같은 에디터 자동완성 모듈에서 오류가 나옵니다.

 

Screenshot 2018-10-17 at 20.25.14.jpg

      function encodeImg($plaintext, $password)
        {

            $password = hash('sha256', $password, true);
            $plaintext = gzcompress($plaintext);
            $iv_source = defined('MCRYPT_DEV_URANDOM') ? MCRYPT_DEV_URANDOM : MCRYPT_RAND;
//            $iv = mcrypt_create_iv(32, $iv_source);
            $iv = random_bytes($iv_source);
            $ciphertext = openssl_encrypt('rijndael-256', $password, $plaintext, 'cbc', $iv);
            $hmac = hash_hmac('sha256', $ciphertext, $password, true);
            return base64_encode($ciphertext . $iv . $hmac);
        }

       $iv = mcrypt_create_iv(32, $iv_source);

 

  php 7.2 에서 mcrypt_ 가 제거 되었다고 하는데 random_bytes 를 쓰라고 하는데  어떻게 고쳐야 하나요?

 

 

 

 

  • profile
    random_bytes(32);
  • profile profile
    이미지가 엑박으로 나오네요... ㅡㅡ;
  • profile profile
    어떤부분에 뭘하는지 모르겠지만.

    random_bytes 함수는 무조건 글자의 길이를 뜻하는 숫자형태(int)의 숫자만 들어가도록 되어있습니다;;
  • profile profile
    ㅎㅎ 알고나면 간단한데 .. 다해놓코 ㅎㅎ 이미지 나오는것도 해결됬습니다.