PHP & Others

encode / decode openssl_encrypt

컨텐츠 정보

본문

class Crypt {
   static private $default_method = "aes-256-cbc";

   public static function doEncrypt($text_to_encrypt) {
      // ...some preparation stuff here
      $result = base64_encode(openssl_encrypt($text_to_encrypt, self::$default_method, $seckey, OPENSSL_RAW_DATA, $iv));
      return $result;
    }

   public static function doDecrypt($encrypted_text) {
      // ...some preparation stuff here
      $result = openssl_decrypt(base64_decode($encrypted_text), self::$default_method, $seckey, OPENSSL_RAW_DATA, $iv);

      return $result;
   }
}

관련자료

댓글 0
등록된 댓글이 없습니다.
Today's proverb
아무리 친한 사이라도 둘 사이를 파괴하고 싶지 않으면, 그리고 오래 지속시키고 싶으면, 어느 정도의 예의는 필요한 법이다. (필립 체스터필드의 “내 아들아 너는 인생을 이렇게 살아라” 중에서)