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
얼마 전에 ‘어릴 때에는 무엇이 되고 싶었습니까?’ 라는 질문을 받은 적이 있습니다. 저는 진지하게 이렇게 대답했습니다. ‘솔 바스요.’ 건방지게 듣지 마십시오. 저는 정말 진정한 제 자신이 되고 싶었습니다. <솔바스, 미국의 영상 디자이너>