public function hash($aPassword, $aSalt, $aMethod) { global $gItoa64; if ($aMethod == self::$HashMethod_sha512b || $aMethod == self::$HashMethod_sha512d) { $Parts = explode(':', $aSalt); $Config = $Parts[0]; $Salt = $Parts[1]; $PreHash = hash('sha512', $Salt . $aPassword); return crypt($PreHash, $Config) . ':' . $Salt; } if ($aMethod == self::$HashMethod_sha512r) { $Parts = explode(':', $aSalt); $CountB2 = intval($Parts[0], 10); $Count = 1 << $CountB2; $Salt = $Parts[1]; $Salt2 = $Parts[2]; $PreHash = hash('sha512', $Salt . $aPassword); $Hash = hash('sha512', $Salt2 . $PreHash, true); do { $Hash = hash('sha512', $Hash . $PreHash, true); } while (--$Count); return '$S$' . $gItoa64[$CountB2] . $Salt2 . encode64($Hash, strlen($Hash)) . ':' . $Salt; } if ($aMethod == self::$HashMethod_sha512s) { return hash('sha512', $aSalt . $aPassword); } return md5($aPassword); }
public function hash($aPassword, $aSalt, $aMethod) { global $gItoa64; if ($aMethod == self::$HashMethod_md5) { return md5($aPassword); } $Parts = explode(':', $aSalt); $CountB2 = intval($Parts[0], 10); $Count = 1 << $CountB2; $Salt = $Parts[1]; $Hash = md5($Salt . $aPassword, true); do { $Hash = md5($Hash . $aPassword, true); } while (--$Count); return '$P$' . $gItoa64[$CountB2] . $Salt . encode64($Hash, 16); }
function encodep($text) { $data = utf8_encode($text); $compressed = gzdeflate($data, 9); return encode64($compressed); }
<?php include '../includes/inc_head.php'; include "../bdd/bdd_connexion.php"; include '../includes/inc_menu.php'; include '../includes/inc_script.php'; $phrase = ''; // Si formulaire envoyé if (isset($_POST['submit'])) { include "../bdd/functions.php"; include "../../classes/Utilisateur.php"; $base64 = ''; if (isset($_FILES['image'])) { include "../functions/uploadIMGbase64.php"; $base64 = encode64($_POST, $_FILES); } if ($_POST['mdp1'] == $_POST['mdp2']) { $nouvelUtilisateur = new Utilisateur(); $nouvelUtilisateur->setEmail("test"); $nouvelUtilisateur->setImage($base64); $nouvelUtilisateur->setNomUtilisateur($_POST["username"]); $nouvelUtilisateur->setMotDePasse($_POST["mdp1"]); $nouvelUtilisateur->setType($_POST["type"]); $nouvelUtilisateur->setNom($_POST["nom"]); $nouvelUtilisateur->setPrenom($_POST["prenom"]); $retour = insererUtilisateur($nouvelUtilisateur); } else { $retour[0] = 1; $retour[1] = "Les mots de passe ne sont pas identiques."; } }
public function hash($aPassword, $aSalt, $aMethod) { global $gItoa64; switch ($aMethod) { case self::$HashMethodMD5s: return md5($aPassword . $aSalt) . ':' . $aSalt; case self::$HashMethodMD5r: $Parts = explode(':', $aSalt); $CountB2 = intval($Parts[0], 10); $Count = 1 << $CountB2; $Salt = $Parts[1]; $Hash = md5($Salt . $aPassword, true); do { $Hash = md5($Hash . $aPassword, true); } while (--$Count); return '$P$' . $gItoa64[$CountB2] . $Salt . encode64($Hash, 16); default: return crypt($aPassword, $aSalt); } }
/** * PHP API Client Code * See http://plantuml.sourceforge.net/codephp.html */ function encodep($text) { $data = mb_convert_encoding($text, 'UTF-8', mb_detect_encoding($text)); $compressed = gzdeflate($data, 9); return encode64($compressed); }
public function hash($aPassword, $aSalt, $aMethod) { global $gItoa64; $Password = $aPassword; $Prefix = ''; switch ($aMethod) { case self::$HashMethod_sha512: $Prefix = '$S$'; break; case self::$HashMethod_usha512: $Password = md5($Password); $Prefix = '$S$'; break; case self::$HashMethod_uhmd5: $Password = md5($Password); $Prefix = 'U$H$'; break; case self::$HashMethod_hmd5: $Prefix = '$H$'; break; case self::$HashMethod_upmd5: $Password = md5($Password); $Prefix = 'U$P$'; break; case self::$HashMethod_pmd5: $Prefix = '$P$'; break; default: break; } $Parts = explode(':', $aSalt); $CountB2 = intval($Parts[0], 10); $Count = 1 << $CountB2; $Salt = $Parts[1]; $Hash = null; if ($aMethod == self::$HashMethod_sha512 || $aMethod == self::$HashMethod_usha512) { $Hash = hash('sha512', $Salt . $Password, TRUE); do { $Hash = hash('sha512', $Hash . $Password, TRUE); } while (--$Count); $Hash = encode64($Hash, 64); } else { $Hash = md5($Salt . $Password, TRUE); do { $Hash = md5($Hash . $Password, TRUE); } while (--$count); $Hash = encode64($Hash, 16); } return substr($Prefix . $gItoa64[$CountB2] . $Salt . $Hash, 0, 55); }