bb_salt

Get salt to add to hashes to help prevent attacks.

Description

(string) bb_salt( (string) $scheme = 'auth' ); 

Returns (string)

Salt value for the given scheme

Parameters (1)

0. $scheme — Optional. (string) => 'auth'
The scheme.

Usage

  1. if ( !function_exists( 'bb_salt' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-pluggable.php'; 
  3.  
  4. // The scheme. 
  5. $scheme = 'auth'; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_salt($scheme); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-includes/functions.bb-pluggable.php  
  1. function bb_salt( $scheme = 'auth' ) 
  2. // Deprecated 
  3. $secret_key = _bb_get_key( 'BB_SECRET_KEY' ); 
  4.  
  5. switch ($scheme) { 
  6. case 'auth': 
  7. $secret_key = _bb_get_key( 'BB_AUTH_KEY' ); 
  8. $salt = _bb_get_salt( array( 'BB_AUTH_SALT', 'BB_SECRET_SALT' ) ); 
  9. break; 
  10.  
  11. case 'secure_auth': 
  12. $secret_key = _bb_get_key( 'BB_SECURE_AUTH_KEY' ); 
  13. $salt = _bb_get_salt( 'BB_SECURE_AUTH_SALT' ); 
  14. break; 
  15.  
  16. case 'logged_in': 
  17. $secret_key = _bb_get_key( 'BB_LOGGED_IN_KEY' ); 
  18. $salt = _bb_get_salt( 'BB_LOGGED_IN_SALT' ); 
  19. break; 
  20.  
  21. case 'nonce': 
  22. $secret_key = _bb_get_key( 'BB_NONCE_KEY' ); 
  23. $salt = _bb_get_salt( 'BB_NONCE_SALT' ); 
  24. break; 
  25.  
  26. default: 
  27. // ensure each auth scheme has its own unique salt 
  28. $salt = hash_hmac( 'md5', $scheme, $secret_key ); 
  29. break; 
  30.  
  31. return apply_filters( 'salt', $secret_key . $salt, $scheme );