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
그대는 신선한 공기와 나무와 풀과 개울이 존재하는 산속에 와 있다. 그 한가운데 앉아서 신이 창조한 세계를 누리도록 하라. (바바하리다스)