×ðÁú¿­Ê±¹ÙÍøµÇ¼

ThinkPHP6ÖÐÔõÑù¾ÙÐÐÊý¾Ý¼ÓÃÜÏ¢ÕùÃܲÙ×÷£¿

Ëæ×Å»¥ÁªÍøÊÖÒÕµÄÒ»Ö±Éú³¤£¬Êý¾Ý¼ÓÃÜÏ¢ÕùÃÜÒ²³ÉΪÁË¿ª·¢Ö°Ô±±Ø±¸µÄÊÖÒÕÖ®Ò»¡£ÔÚʹÓÃthinkphp6¿ò¼Ü¾ÙÐпª·¢Ê±£¬Ò²ÐèÒªÏàʶÔõÑù¾ÙÐÐÊý¾ÝµÄ¼ÓÃÜÏ¢ÕùÃܲÙ×÷¡£

±¾ÎĽ«ÏêϸÏÈÈÝThinkPHP6ÖеÄÊý¾Ý¼ÓÃÜÏ¢ÕùÃܲÙ×÷¡£

Ò»¡¢Êý¾Ý¼ÓÃÜ

1.ʹÓÃϵͳº¯Êý¼ÓÃÜ

PHPÌṩÁËһЩϵͳº¯Êý¿ÉÒÔÓÃÀ´¶ÔÊý¾Ý¾ÙÐмÓÃÜ£¬ÆäÖÐ×î³£ÓõÄÊÇmd5()º¯Êý£¬´Ëº¯Êý¿ÉÒÔ½«×Ö·û´®¾ÙÐÐMD5¼ÓÃܲ¢·µ»Ø32볤¶ÈµÄÃÜÎÄ×Ö·û´®£¬ÈçÏÂËùʾ£º

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

$str = 'hello,world';
$encryptedStr = md5($str);
echo $encryptedStr;

µÇ¼ºó¸´ÖÆ

Êä³ö£º3e25960a79dbc69b674cd4ec67a72c62

2.ThinkPHP6ÖеÄÊý¾Ý¼ÓÃÜÒªÁì

ÔÚThinkPHP6ÖУ¬Ðí¶à³£ÓõļÓÃÜÒªÁ춼ÒѾ­·â×°ºÃÁË¡£Ê¹ÓüÓÃÜÒªÁìÐèÒªÔÚÉèÖÃÎļþÖоÙÐÐÉèÖã¬ÈçÏÂËùʾ£º

// config/app.php
return [
    // ...
    'default_return_type' => 'json',
    'encrypt_key'         => '123456', // ¼ÓÃÜÃÜÔ¿£¬ÉèÖúó¿ÉÒÔ×Ô¶¯¶ÔÊý¾Ý¾ÙÐмÓÃÜ
];

µÇ¼ºó¸´ÖÆ

ÉèÖÃÍê³ÉÖ®ºó£¬ÔÚ¿ØÖÆÆ÷ÖÐʹÓüÓÃÜÒªÁì¼´¿É£¬ÈçÏÂËùʾ£º

public function test()
{
    $data = [
        'name' => 'ÕÅÈý',
        'age' => 25
    ];
    $encryptedData = encrypt($data);
    echo $encryptedData;
}

µÇ¼ºó¸´ÖÆ

Êä³ö£º7CjHCP++pLmJECzJr6a+Q7WpAbi+HVV4kHQNnpLQkVoBiVvRywim4JsRHqz153F2FJFMR6OYZT78gLvS0K9nmOiLCsQkExz+

¶þ¡¢Êý¾Ý½âÃÜ

1.ʹÓÃϵͳº¯Êý½âÃÜ

ÓëMD5¼ÓÃܲî±ð£¬MD5½âÃÜÊÇÒ»ÖÖÎÞ·¨ÊµÏֵIJÙ×÷¡£ÔÚ½âÃÜÊý¾Ýʱ£¬ÎÒÃÇÐèҪʹÓÃÆäËûµÄ½âÃÜÒªÁì¡£ÔÚPHPÖÐÒ²ÌṩÁËÐí¶à½âÃܺ¯Êý£¬ÀýÈçbase64_decode()º¯Êý£¬¿ÉÒÔ½«Ê¹ÓÃBase64±àÂëµÄ×Ö·û´®½âÃܳÉԭʼÊý¾Ý¡£Ê¹ÓÃʾÀýÈçÏ£º

$encryptedStr = 'aGVsbG8sIHdvcmxk'; // ¼ÓÃܺóµÄ×Ö·û´®
$decryptedStr = base64_decode($encryptedStr); // ½âÃܺóµÄ×Ö·û´®
echo $decryptedStr;

µÇ¼ºó¸´ÖÆ

Êä³ö£ºhello, world

2.ThinkPHP6ÖеÄÊý¾Ý½âÃÜÒªÁì

ÔÚThinkPHP6¿ò¼ÜÖУ¬¹ØÓÚʹÓüÓÃÜÒªÁì¼ÓÃܵÄÊý¾Ý£¬ÐèҪʹÓÃdecrypt($encryptedData)º¯Êý¾ÙÐнâÃÜ£¬ÈçÏÂËùʾ£º

public function test()
{
    $encryptedData = '7CjHCP++pLmJECzJr6a+Q7WpAbi+HVV4kHQNnpLQkVoBiVvRywim4JsRHqz153F2FJFMR6OYZT78gLvS0K9nmOiLCsQkExz+';
    $decryptedData = decrypt($encryptedData);
    dump($decryptedData);
}

µÇ¼ºó¸´ÖÆ

ÔÚ½âÃÜ֮ǰ£¬ÐèҪȷ¶¨¼ÓÃÜÃÜÔ¿ÊÇ·ñ׼ȷ£¬ÈôÊÇÉèÖõļÓÃÜÃÜÔ¿Óë½âÃÜÃÜÔ¿·×ÆçÖ£¬ÔòÎÞ·¨Õý³£¾ÙÐÐÊý¾Ý½âÃܲÙ×÷¡£

Èý¡¢×¢ÖØÊÂÏî

ÔÚʹÓÃÊý¾Ý¼ÓÃÜÏ¢ÕùÃÜʱ£¬ÐèҪעÖØÒÔϼ¸µã£º

×èÖ¹ÃÜԿй¶£¬ÃÜÔ¿Ò»µ©Ð¹Â¶£¬Êý¾Ý½«ÎÞ·¨±£ÃÜ¡£

×èֹäĿʹÓüÓÃܲÙ×÷£¬²»ÊÇËùÓеÄÊý¾Ý¶¼ÐèÒª¾ÙÐмÓÃÜ¡£

°´ÆÚÌæ»»ÃÜÔ¿£¬±ÜÃâÃÜÔ¿±»ÆƽâºóÊý¾Ýй¶¡£

ÒÔÉϾÍÊǹØÓÚThinkPHP6ÖÐÊý¾Ý¼ÓÃÜÏ¢ÕùÃܲÙ×÷µÄÏêϸÏÈÈÝ¡£ÕÆÎÕÁ˼ÓÃÜÏ¢ÕùÃܵÄÒªÁ죬¿ÉÒÔÓÐÓñ£»¤Êý¾ÝµÄÇå¾²¡£ÔÚ¾ÙÐÐÏÖʵ¿ª·¢Ê±£¬ÐèÒªÒÀ¾ÝÏêϸÇéÐÎ×ÛºÏʹÓÃÖÖÖÖ¼ÓÃÜËã·¨À´±£»¤Êý¾ÝµÄÇå¾²¡£

ÒÔÉϾÍÊÇThinkPHP6ÖÐÔõÑù¾ÙÐÐÊý¾Ý¼ÓÃÜÏ¢ÕùÃܲÙ×÷£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ