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
고개에 오르려고 하다가 꼭대기에 이르지 못했다 하더라도 얼마나 칭찬할 만한 일인가. 자기의 현재의 힘으로 자신을 되돌아보고, 애써 고매한 일을 하면서도 더 커다란 일을 그려본다는 것은 대단히 귀중한 일이다. (세네카)