wp_hash

函数
wp_hash ( $data, $scheme = 'auth' )
参数
  • (string) $data Plain text to hash.
    Required:
  • (string) $scheme Authentication scheme (auth, secure_auth, logged_in, nonce).
    Required:
    Default: 'auth'
返回值
  • (string) Hash of $data.
定义位置
相关方法
wp_slashwp_headwp_unslashwp_dashboardwp_rss
引入
2.0.3
弃用
-

wp_hash: 这个函数用于生成一个字符串的哈希值。它把要散列的字符串作为一个参数,并返回散列的字符串。

获取给定字符串的哈希值。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_hash( $data, $scheme = 'auth' ) {
$salt = wp_salt( $scheme );
return hash_hmac( 'md5', $data, $salt );
}
endif;
if ( ! function_exists( 'wp_hash_password' ) ) :
/**
* Creates a hash (encrypt) of a plain text password.
*
* For integration with other applications, this function can be overwritten to
* instead use the other package password checking algorithm.
*
* @since 2.5.0
*
* @global PasswordHash $wp_hasher PHPass object
*
* @param string $password Plain text user password to hash.
* @return string The hash string of the password.
*/
function wp_hash( $data, $scheme = 'auth' ) { $salt = wp_salt( $scheme ); return hash_hmac( 'md5', $data, $salt ); } endif; if ( ! function_exists( 'wp_hash_password' ) ) : /** * Creates a hash (encrypt) of a plain text password. * * For integration with other applications, this function can be overwritten to * instead use the other package password checking algorithm. * * @since 2.5.0 * * @global PasswordHash $wp_hasher PHPass object * * @param string $password Plain text user password to hash. * @return string The hash string of the password. */
function wp_hash( $data, $scheme = 'auth' ) {
		$salt = wp_salt( $scheme );

		return hash_hmac( 'md5', $data, $salt );
	}
endif;

if ( ! function_exists( 'wp_hash_password' ) ) :
	/**
	 * Creates a hash (encrypt) of a plain text password.
	 *
	 * For integration with other applications, this function can be overwritten to
	 * instead use the other package password checking algorithm.
	 *
	 * @since 2.5.0
	 *
	 * @global PasswordHash $wp_hasher PHPass object
	 *
	 * @param string $password Plain text user password to hash.
	 * @return string The hash string of the password.
	 */

常见问题

FAQs
查看更多 >