Ejemplo n.º 1
0
 /**
  * Check if a clear password match encrypt password
  *
  * @param string
  * @param string
  * @return bool
  */
 public static function checkPassword($clear, $encrypt)
 {
     if (substr($encrypt, 0, 6) == '$apr1$') {
         if (USVN_Crypt::_cryptApr1MD5($clear, $encrypt) == $encrypt) {
             return true;
         }
         return false;
     }
     if (crypt($clear, $encrypt) == $encrypt) {
         return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 public function testApr1MD5()
 {
     $crypt = USVN_Crypt::_cryptApr1MD5("toto", "A.IgA/..");
     $this->assertEquals($crypt, '$apr1$A.IgA/..$vcK1pKAvkEGvAT0ob46Bw0');
     $this->assertEquals($crypt, USVN_Crypt::_cryptApr1MD5("toto", $crypt));
     $crypt = USVN_Crypt::_cryptApr1MD5("toto", "A.IgA/a.");
     $this->assertNotEquals($crypt, '$apr1$A.IgA/..$vcK1pKAvkEGvAT0ob46Bw0');
     $this->assertEquals($crypt, USVN_Crypt::_cryptApr1MD5("toto", $crypt));
     $crypt = USVN_Crypt::_cryptApr1MD5("toto");
     $this->assertNotEquals($crypt, '$apr1$A.IgA/..$vcK1pKAvkEGvAT0ob46Bw0');
     $this->assertEquals($crypt, USVN_Crypt::_cryptApr1MD5("toto", $crypt));
     $crypt = USVN_Crypt::_cryptApr1MD5("bidulmachinsuperlong");
     $this->assertEquals($crypt, USVN_Crypt::_cryptApr1MD5("bidulmachinsuperlong", $crypt));
 }