password_compat-masterPHP5.5密碼功能PHP函式庫
<?php /** * A Compatibility library with PHP 5.5's simplified password hashing API. * * @author Anthony Ferrara <ircmaxell@php.net> * @license http://www.opensource.org/licenses/mit-license.html MIT License * @copyright 2012 The Authors */ namespace { if (!defined('PASSWORD_BCRYPT')) { /** * PHPUnit Process isolation caches constants, but not function declarations. * So we need to check if the constants are defined separately from * the functions to enable supporting process isolation in userland * code. */ define('PASSWORD_BCRYPT', 1); define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); define('PASSWORD_BCRYPT_DEFAULT_COST', 10); }
相信很多PHP開發者在最先接觸PHP的時候,處理密碼的首選加密函數可能就是MD5了,我當時就是這樣的:
$password = md5($_POST["password "]);
上面這段程式碼是不是很熟悉?然而MD5的加密方式目前在PHP的江湖中貌似不太受歡迎了,因為它的加密演算法實在是顯得有點簡單了,而且很多破解密碼的站點都存放了很多經過MD5加密的密碼字符串,所以這裡我是非常不提倡還在單單使用MD5來加密使用者的密碼的。
SHA256 和 SHA512
其實跟前面的MD5同期的還有一個SHA1加密方式的,不過也是演算法比較簡單,所以這裡就一筆帶過吧。而這裡即將要說到的SHA256 和 SHA512都是來自於SHA2家族的加密函數,看名字可能你就猜的出來了,這兩個加密方式分別產生256和512位元長度的hash字符串。
免責聲明
本站所有資源皆由網友貢獻或各大下載網站轉載。請自行檢查軟體的完整性!本站所有資源僅供學習參考。請不要將它們用於商業目的。否則,一切後果都由您負責!如有侵權,請聯絡我們刪除。聯絡方式:admin@php.cn
相關文章

26 Dec 2024
嘿,加密創新者!準備好增強 Go 的加密包了嗎?雖然 Go 的標準加密工具包非常棒,但有時我們需要額外的功能。讓我們探索如何使用一些很酷的第三方函式庫來擴展我們的加密功能


Hot Tools

熱門文章
丟失記錄:Bloom&Rage -Corey和Dylan的鎖組合
19 Feb 2025
手游攻略
王國來:拯救2-婚禮要買的衣服
05 Feb 2025
手游攻略
Hello Kitty Island冒險:重新啟動機器人任務演練
16 Feb 2025
手游攻略
丟失的記錄:Bloom&Rage-成就/獎杯指南
19 Feb 2025
手游攻略
王國來:拯救2-如何獲得Comfrey
07 Feb 2025
手游攻略