Source for file crypt.php

Documentation is available at crypt.php

  1. <?php
  2. /**
  3. * Test of authentication object logic - crypt'ed passwords
  4. *
  5. @author    Stuart Prescott
  6. @copyright  Copyright Stuart Prescott
  7. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  8. @version    $Id$
  9. @package    Bumblebee
  10. @subpackage Tests
  11. */
  12.  
  13. ini_set('error_reporting'E_ALL);
  14.  
  15. set_include_path('../../../');
  16. require 'inc/bb/basicauth.php';
  17.  
  18.  
  19. $pass 'foobar';
  20.  
  21. $methods array('md5''md5_compat''md5_emulated''des''sha1');
  22.  
  23. foreach ($methods as $m{
  24.   
  25.   print "Using method $m\n";
  26.   print $enc makePasswordHash($passNULL$m);
  27.   print "\n";
  28.  
  29.   print makePasswordHash($pass$enc);
  30.   print "\n";
  31.   
  32.   print "strlen=".strlen($enc)."\n";
  33. }
  34.  
  35.  
  36. // test that the md5 and md5_emulated methods do the same thing
  37. print "\nTest custom md5 methods\n";
  38. $salt makeHashSalt('md5');
  39. $enc1 makePasswordHash($pass$salt);
  40. #print $salt."\n";
  41. $enc1 substr($enc1strrpos($enc1'$')+1);
  42.  
  43. $salt '$md5$'.substr($salt,3);
  44. $enc2 makePasswordHash($pass$salt);
  45. #print $salt."\n";
  46. $enc2 substr($enc2strrpos($enc2'$')+1);
  47.  
  48. print $enc1 "\n" $enc2 "\n" ($enc1==$enc2 "PASS: passwords match\n" "FAIL: no match\n");
  49.  
  50. // test that the sha1 and sha1_binary methods do the same thing
  51. print "\nTest custom sha1 methods\n";
  52. $salt makeHashSalt('sha1');
  53. $enc1 makePasswordHash($pass$salt);
  54. #print $salt."\n";
  55. $enc1 substr($enc1strrpos($enc1'$')+1);
  56.  
  57. $salt '$sha1_binary$'.substr($salt,6);
  58. $enc2 makePasswordHash($pass$salt);
  59. #print $salt."\n";
  60. $enc2 substr($enc2strrpos($enc2'$')+1);
  61.  
  62. print $enc1 "\n" $enc2 "\n" ($enc1==$enc2 "PASS: passwords match\n" "FAIL: no match\n");
  63.  
  64. ?>

Documentation generated on Tue, 06 Mar 2007 10:01:10 +0000 by phpDocumentor 1.3.0