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;
   }
}

관련자료

등록된 댓글이 없습니다.
Today's proverb
전반전이 끝난 상황이라면 절대로 중단하지 말라. 전반전 점수는 큰 의미가 없다. 그 너머를 보라. 승리할 수 있는 길은 끝까지 인내하는 것이다.