PHP DES 암호화 및 복호화 방법 코드

little bottle
풀어 주다: 2023-04-05 21:50:01
앞으로
2226명이 탐색했습니다.

이 글은 주로 PHP의 DES 암호화 및 복호화 방법의 코드 내용에 관한 것입니다.

test.php 테스트 파일

<?php
require_once(&#39;Des.php&#39;);

$des = new Des();

$data[&#39;a&#39;] = &#39;a&#39;;
$data[&#39;b&#39;] = &#39;b&#39;;

$conf = [&#39;appkey&#39;=>&#39;AbcdefghijklmnopqrstuvwX&#39;,&#39;secretcode&#39;=>&#39;Abcdefgh&#39;];

$encode = $des->encode($data, $conf);

print_r($encode);
echo "<br>";

$decode = $des->decode($encode,$conf);

print_r($decode);

?>
로그인 후 복사

Des.php

<?php

require_once(&#39;TripleDES.php&#39;);

class Des {

    public static function encode($data, $configKey) {
        $tripleDes = new TripleDES();
        if (is_array($data)) {
            $data = json_encode($data);
        }
        return $tripleDes->encode($data, $configKey["appkey"], $configKey["secretcode"]);
    }

    public static function decode($data, $configKey) {
        $tripleDes = new TripleDES();
        return $tripleDes->decode($data, $configKey["appkey"], $configKey["secretcode"]);
    }

    public static function encodeArr($data, $configKey) {
        $data = json_encode($data);
        return self::encode($data, $configKey);
    }

    public static function decodeArr($data, $configKey) {
        $res = self::decode($data, $configKey);
        return json_decode($res,true);
    }

}
로그인 후 복사

관련 튜토리얼: PHP 비디오 튜토리얼#🎜 🎜#

위 내용은 PHP DES 암호화 및 복호화 방법 코드의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
php
원천:cnblogs.com
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!