本文整理汇总了PHP中getSalt函数的典型用法代码示例。如果您正苦于以下问题:PHP getSalt函数的具体用法?PHP getSalt怎么用?PHP getSalt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSalt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getSalt
protected function getSalt()
{
if (isset($_POST['password'])) {
return getSalt();
} else {
return false;
}
}
开发者ID:yunsite,项目名称:nuomituan,代码行数:8,代码来源:UserModel.class.php
示例2: getPasswordHash
function getPasswordHash($id, $password, $fixedsalt)
{
$salt = getSalt($id, $fixedsalt);
$hash = '';
//ストレッチング
for ($i = 0; $i < 1000; $i++) {
$hash = hash('sha256', $hash . $password . $salt);
}
return $hash;
}
开发者ID:soutaito,项目名称:IMIDataConverter,代码行数:10,代码来源:utility.php
示例3: set_address
function set_address($id, $address)
{
#Sets address of user with id
$id = mysql_real_escape_string($id);
$address = mysql_real_escape_string($address);
global $aes_password;
$salt = getSalt($id);
$ret = true;
$query = "UPDATE users SET enc_address = AES_ENCRYPT('{$address}', '{$aes_password}{$salt}') WHERE id = {$id}";
mysql_query($query) or $ret = false;
return $ret;
}
开发者ID:henrikssn,项目名称:OpenPool,代码行数:12,代码来源:db.php
示例4: changePassword
function changePassword($username, $newPassword)
{
$userArray = [];
include "getUsersFromJSON.php";
if (!empty($userArray)) {
for ($i = 0; $i < sizeof($userArray); $i++) {
if ($userArray[$i]->{'username'} == $username) {
$userArray[$i]->{'password'} = crypt($newPassword, getSalt());
break;
}
}
$path_config_users = "";
include "paths.php";
file_put_contents($path_config_users, json_encode($userArray, JSON_PRETTY_PRINT));
}
}
开发者ID:DeadSpaghetti,项目名称:codera,代码行数:16,代码来源:functions.php
示例5: passwd
function passwd($oldpwd, $newpwd)
{
global $session;
global $dbh;
if (!valid_passwd($oldpwd) || !valid_user($session['user'], $oldpwd, $privilege)) {
echo "&error 3";
return;
}
if (valid_passwd($newpwd)) {
$query = sprintf("UPDATE users SET pass=%s WHERE user=%s", $dbh->quote(crypt($newpwd, getSalt())), $dbh->quote($session['user']));
if ($dbh->exec($query) == 1) {
echo "&end";
return;
} else {
echo "&error 5";
}
} else {
echo "&error 4";
}
}
开发者ID:scovit,项目名称:nust-helico,代码行数:20,代码来源:user.php
示例6: login
public function login()
{
//Gather data from AJAX
$data = json_decode(file_get_contents('php://input'), true);
$return['error'] = -3;
$return['value'] = null;
//Sanitise inputs
$result = $this->checkInput($data, array('username', 'password'));
if ($result == '') {
//Check if UID exists
$uid = getUserUID($data['username']);
if ($uid == null) {
$return['error'] = -2;
$return['value'] = "Invalid credentials";
} else {
$saltedPw = crypt($data['password'], getSalt($data['username']));
if (checkSaltedPass($data['username'], $saltedPw)) {
//Generates salt for username
$salt = $this->generateSalt();
//Authenticated token
$token = $data['username'] . $salt;
//Authentication information
$cookievars['username'] = $data['username'];
$cookievars['salt'] = $salt;
//Creates cookie with name of authenticated token,
setcookie(user_encrypt($token), json_encode($cookievars), 0, "/");
//Returns with authenticated token
$return['error'] = 0;
$return['value'] = user_encrypt($token);
} else {
$return['error'] = -2;
$return['value'] = "Invalid credentials";
}
}
} else {
$return['error'] = -1;
$return['value'] = $result;
}
$jsonstring = json_encode($return);
echo $jsonstring;
}
开发者ID:tonyward,项目名称:Teameet,代码行数:41,代码来源:accounts.php
示例7: overrideUserProperties
function overrideUserProperties($username, $password, $forbiddenProjects, $accountType, $newUsername)
{
$userArray = [];
include "getUsersFromJSON.php";
$path_config_users = "";
include "paths.php";
if (!empty($userArray)) {
for ($i = 0; $i < sizeof($userArray); $i++) {
if ($userArray[$i]->{'username'} == $username) {
if ($username != "admin" && $username != "public") {
if ($username == "New User" && $newUsername != "admin" && $newUsername != "public") {
$username = $newUsername;
}
if (isset($newUsername) && $newUsername != "admin" && $newUsername != "public") {
$username = $newUsername;
}
$userArray[$i]->{'username'} = $username;
$userArray[$i]->{'forbiddenProjects'} = $forbiddenProjects;
$userArray[$i]->{'accountType'} = $accountType;
} elseif ($username == "public") {
$userArray[$i]->{'username'} = "public";
$userArray[$i]->{'forbiddenProjects'} = $forbiddenProjects;
$userArray[$i]->{'accountType'} = "user";
} elseif ($username == "admin") {
$userArray[$i]->{'username'} = "admin";
$userArray[$i]->{'accountType'} = "admin";
$userArray[$i]->{'forbiddenProjects'} = "[]";
}
if (isset($password) && $password != "" && !is_null($password) && $username != "public") {
$userArray[$i]->{'password'} = crypt($password, getSalt());
}
include_once "functions.php";
file_put_contents($path_config_users, json_encode(getSortedUserArray($userArray), JSON_PRETTY_PRINT));
break;
}
}
}
}
开发者ID:DeadSpaghetti,项目名称:codera,代码行数:38,代码来源:addUserToJSON.php
示例8: password
function password($pass)
{
// following CakePHP hash method
return sha1(getSalt() . $pass);
}
开发者ID:ivanbautsita,项目名称:gestion-escolar-campus-virtuales,代码行数:5,代码来源:config.php
示例9: crypt
$userArray = [];
include "getUsersFromJSON.php";
for ($i = 0; $i < sizeof($userArray); $i++) {
if ($userArray[$i]->{'username'} == $username) {
if ($userArray[$i]->{'password'} == $password) {
$_SESSION['loggedIn'] = $username;
$returnValue = $userArray[$i]->{'accountType'};
} else {
//wrong password --> returnValue doesn't need to be changed!
}
break;
}
}
echo $returnValue;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
if (isset($username) && isset($password) && $username != "" && $password != "") {
include_once "functions.php";
$password = crypt($password, getSalt());
if (file_exists($path_config_users)) {
checkLoginData($username, $password);
} else {
echo 'failure';
//file doesn't exist
}
} else {
echo "wrongInput";
}
}
开发者ID:DeadSpaghetti,项目名称:codera,代码行数:31,代码来源:checkLogin.php
示例10: mysqli_connect
</form>
<?php
if (isset($_POST['username']) && isset($_POST['g-recaptcha-response'])) {
if (isValid()) {
if (strlen($_POST['username']) >= 8) {
if (strlen($_POST['phone']) == countDigits($_POST['phone'])) {
$con = mysqli_connect("localhost", "root", "PASS", "secure_login");
if (mysqli_connect_errno()) {
die('Could not connect: ' . mysqli_connect_error());
}
$result = mysqli_query($con, "SELECT username FROM members WHERE username='" . $_POST['username'] . "'");
if (mysqli_num_rows($result) == 0) {
$result = mysqli_query($con, "SELECT email FROM members WHERE email='" . strtolower($_POST['email']) . "'");
if (mysqli_num_rows($result) == 0) {
mysqli_query($con, "INSERT INTO members (username, password, email, phone, salt, recoveryid, recoveryValid) VALUES ('" . $_POST['username'] . "','" . strtoupper(getSalt()) . "','" . strtolower($_POST['email']) . "','" . $_POST['phone'] . "','" . strtoupper(getSalt()) . "','" . generateRandomString(16) . "','" . date("d/m/Y") . "')");
send_mail();
mysqli_close($con);
$pieces = explode("@", $_POST['email']);
echo "Thank you for your registration. <br/>";
echo "Please check <a href=\"" . $pieces[1] . "\">your email</a> to activate your account.";
} else {
echo "There is already an account associated with this email. <a href=\"index.php\">Login</a>";
}
} else {
echo "This username is already in use. Please try another username.";
}
} else {
echo 'The entered phone number does not seem to be valid. Please check it and try again. ([0-9])';
}
} else {
开发者ID:CodeSurfing145,项目名称:Wallet-Finder,代码行数:31,代码来源:register.php
示例11: getCryptedPassword
function getCryptedPassword($plaintext, $salt = '', $encryption = 'md5-hex', $show_encrypt = false)
{
// Get the salt to use.
$salt = getSalt($encryption, $salt, $plaintext);
// Encrypt the password.
switch ($encryption) {
case 'plain':
return $plaintext;
case 'sha':
$encrypted = base64_encode(mhash(MHASH_SHA1, $plaintext));
return $show_encrypt ? '{SHA}' . $encrypted : $encrypted;
case 'crypt':
case 'crypt-des':
case 'crypt-md5':
case 'crypt-blowfish':
return ($show_encrypt ? '{crypt}' : '') . crypt($plaintext, $salt);
case 'md5-base64':
$encrypted = base64_encode(mhash(MHASH_MD5, $plaintext));
return $show_encrypt ? '{MD5}' . $encrypted : $encrypted;
case 'ssha':
$encrypted = base64_encode(mhash(MHASH_SHA1, $plaintext . $salt) . $salt);
return $show_encrypt ? '{SSHA}' . $encrypted : $encrypted;
case 'smd5':
$encrypted = base64_encode(mhash(MHASH_MD5, $plaintext . $salt) . $salt);
return $show_encrypt ? '{SMD5}' . $encrypted : $encrypted;
case 'aprmd5':
$length = strlen($plaintext);
$context = $plaintext . '$apr1$' . $salt;
$binary = JUserHelper::_bin(md5($plaintext . $salt . $plaintext));
for ($i = $length; $i > 0; $i -= 16) {
$context .= substr($binary, 0, $i > 16 ? 16 : $i);
}
for ($i = $length; $i > 0; $i >>= 1) {
$context .= $i & 1 ? chr(0) : $plaintext[0];
}
$binary = JUserHelper::_bin(md5($context));
for ($i = 0; $i < 1000; $i++) {
$new = $i & 1 ? $plaintext : substr($binary, 0, 16);
if ($i % 3) {
$new .= $salt;
}
if ($i % 7) {
$new .= $plaintext;
}
$new .= $i & 1 ? substr($binary, 0, 16) : $plaintext;
$binary = JUserHelper::_bin(md5($new));
}
$p = array();
for ($i = 0; $i < 5; $i++) {
$k = $i + 6;
$j = $i + 12;
if ($j == 16) {
$j = 5;
}
$p[] = JUserHelper::_toAPRMD5(ord($binary[$i]) << 16 | ord($binary[$k]) << 8 | ord($binary[$j]), 5);
}
return '$apr1$' . $salt . '$' . implode('', $p) . JUserHelper::_toAPRMD5(ord($binary[11]), 3);
case 'md5-hex':
default:
$encrypted = $salt ? md5($plaintext . $salt) : md5($plaintext);
return $show_encrypt ? '{MD5}' . $encrypted : $encrypted;
}
}
开发者ID:nuthankumarns,项目名称:Edulab-web-services,代码行数:63,代码来源:account.php
示例12: ini_set
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
include 'functions.php';
if (isset($_GET['email']) && isset($_GET['password'])) {
$con = mysqli_connect("localhost", "root", "PASS", "secure_login");
if (mysqli_connect_errno()) {
die('Could not connect: ' . mysqli_connect_error());
}
$result = mysqli_query($con, "SELECT email FROM members WHERE email='" . strtolower($_GET['email']) . "'");
if (mysqli_num_rows($result) != 0) {
$result = mysqli_fetch_assoc(mysqli_query($con, "SELECT * FROM members WHERE email='" . strtolower($_GET['email']) . "'"));
if (strtoupper(hash('sha512', $_GET['password'] . $result['salt'])) == $result['password']) {
$_SESSION['login'] = getSalt();
$_SESSION['loginTime'] = date('H:i:s');
$_SESSION['loginDate'] = date('Y/m/d ');
$_SESSION['email'] = $_GET['email'];
$_SESSION['username'] = $result['username'];
$_SESSION['phone'] = $result['phone'];
mysqli_query($con, "DELETE FROM `sessions` WHERE `sessions`.`email` = '" . strtolower($_GET['email']) . "'");
mysqli_query($con, "INSERT INTO sessions (email, sessionId, loginTime, loginDate) VALUES ('" . strtolower($_GET['email']) . "', '" . $_SESSION['login'] . "', '" . $_SESSION['loginTime'] . "', '" . $_SESSION['loginDate'] . "')");
if (check_login() == 0) {
echo 'LOGIN_SUCCESS<br />' . $_SESSION['login'] . '<br />' . $_SESSION['username'] . '<br />' . $_SESSION['email'] . '<br />' . $_SESSION['phone'];
} else {
if (check_login() == 1) {
echo 'ERROR_EXPIRED';
session_destroy();
}
}
开发者ID:CodeSurfing145,项目名称:Wallet-Finder,代码行数:30,代码来源:index_mobile.php
示例13: session_start
<?php
if (!isset($_SESSION)) {
session_start();
}
include_once "functions.php";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$oldPassword = $_POST['oldPassword'];
$username = $_SESSION['loggedIn'];
$password = $_POST['password'];
if (isUserAdmin($username) || isset($oldPassword) && crypt($oldPassword, getSalt()) == getPassword($username)) {
include_once "functions.php";
changePassword($username, $password);
} else {
echo "denied";
}
}
开发者ID:DeadSpaghetti,项目名称:codera,代码行数:17,代码来源:changeUserPassword.php
示例14: checkCookies
function checkCookies(&$forceLogin, &$error, $ignoreBlanks)
{
$forceLogin = TRUE;
$error = "";
global $sessionDuration;
dbgSquirt("==============Function: checkCoookies ==============");
dbgSquirt('Cookie --' . dbgShowFile($_COOKIE));
if (isset($_COOKIE['user']) && !empty($_COOKIE['user']) && isset($_COOKIE['authentication']) && !empty($_COOKIE['authentication'])) {
// both user and authentication cookies are set and non-blank
// dbgSquirt("Cookies set and non-empty");
$userCookie = $_COOKIE['user'];
$authenticationCookie = $_COOKIE['authentication'];
$time = time();
// dbgSquirt("Getting salt");
if (getSalt($salt)) {
// dbgSquirt("...salt gotten");
// dbgSquirt("Encrypting");
if (sha1($userCookie . $salt) == $authenticationCookie) {
// authentication passed
// so reset expiration on cookies
// dbgSquirt("Cookie matches encryption");
// dbgSquirt("Resetting cookies");
// dbgSquirt("Time -- $time");
// dbgSquirt("Time + Duration -- ". ($time+$sessionDuration));
$result = setcookie("user", $userCookie, $time + $sessionDuration);
$result1 = setcookie("authentication", $authenticationCookie, $time + $sessionDuration);
if (TRUE == $result && TRUE == $result1) {
// everything worked
// dbgSquirt("Everything worked ... no need to forceLogin");
$forceLogin = FALSE;
} else {
$error = "Internal error -- problem while creating cookies. Please contact an administrator.";
}
} else {
// credentials in cookies don't match.
// dbgSquirt("Cookie does NOT match encryption");
$error = "Authentication error -- The supplied credentials don't match our stored values. Please reauthenticate and try again.";
}
} else {
// dbgSquirt("...error while getting salt");
// error while trying to get salt value
$error = "Internal error -- unable to validate supplied credentials. Please reauthenticate and try again.";
}
} else {
// cookies were unset or contained empty values
// dbgSquirt("Cookies unset or empty");
if (FALSE == $ignoreBlanks) {
$error = "Please log in.";
}
}
dbgSquirt("Returning -- " . empty($error));
return empty($error);
}
开发者ID:runamedia,项目名称:resiprocate,代码行数:53,代码来源:reprofunctions.php
示例15: getHashedPassword
public function getHashedPassword($userName, $password)
{
$salt = getSalt($userName);
$passwordHashed = crypt($password, $salt);
return substr($passwordHashed, strlen($salt));
}
开发者ID:Amfys,项目名称:BST,代码行数:6,代码来源:db.php
示例16: createPassword
$username = $_POST['username'];
$password = $_POST['password'];
$encryptedPassword = createPassword($username, $password);
$state = validateUser($username, $encryptedPassword);
if ("N" == $state) {
dbgSquirt('Not a valid user');
$error = "Authentication error -- Invalid username/password combination.";
} else {
if ("A" == $state) {
// active account and username/password match
dbgSquirt('Active account matched.');
// if we haven't already looked up the salt, do so now
$result = TRUE;
if (empty($salt)) {
dbgSquirt('Getting salt');
$result = getSalt($salt);
}
if (FALSE == $result) {
// uh-oh ... we got an error getting the salt
dbgSquirt('Error in getSalt');
$error = "Internal error -- failure while processing login. Please contact an administrator.";
} else {
dbgSquirt('Extending cookies');
dbgSquirt("Time -- {$time}");
dbgSquirt("Time + Duration -- " . ($time + $sessionDuration));
$result = setcookie("user", $username, $time + $sessionDuration);
$result1 = setcookie("authentication", sha1($username . $salt), $time + $sessionDuration);
if (TRUE == $result && TRUE == $result1) {
// everything worked
dbgSquirt('Everything worked.');
$forceLogin = FALSE;
开发者ID:runamedia,项目名称:resiprocate,代码行数:31,代码来源:userhome.php
示例17: chgpwd
public function chgpwd()
{
if (!$this->isPost()) {
$this->user('修改密码');
exit;
}
$id = getUserId();
$oldpassword = $this->_post('oldpassword', 'mysql_escape_string');
$password = $this->_post('password', 'mysql_escape_string');
$model = D("User");
$data = $model->where("id={$id}")->find();
//校验
if ($data['password'] == pwdHash($oldpassword . $data['salt'])) {
$data['salt'] = getSalt();
$data['password'] = pwdHash($password . $data['salt']);
$model->where("id={$id}")->save($data);
$this->success($model->getError());
} else {
$this->error("原密码错误!");
}
}
开发者ID:yunsite,项目名称:nuomituan,代码行数:21,代码来源:UserAction.class.php
示例18: hashPasswd
function hashPasswd($password)
{
return md5($password . getSalt());
}
开发者ID:netlor,项目名称:private_diplo,代码行数:4,代码来源:helpers.php
示例19: mq
}
mq("UPDATE users SET firstname='" . addslashes($_POST["firstname"]) . "', lastname='" . addslashes($_POST["lastname"]) . "', login='" . addslashes($_POST["login"]) . "', email='" . addslashes($_POST["email"]) . "' WHERE id='" . intval($_POST["id"]) . "';");
$_REQUEST["msg"] = _("Account edited successfully");
$_REQUEST["action"] = "";
}
break;
case "docreate":
// CREATE
// search for existing login :
$already = mqone("SELECT * FROM users WHERE login='" . addslashes($_POST["login"]) . "';");
if ($already) {
$_REQUEST["error"] = _("This login is already used, please choose another one");
$_REQUEST["action"] = "create";
} else {
$pass = mkpass();
mq("INSERT INTO users SET firstname='" . addslashes($_POST["firstname"]) . "', lastname='" . addslashes($_POST["lastname"]) . "', login='" . addslashes($_POST["login"]) . "', email='" . addslashes($_POST["email"]) . "', pass='" . crypt($pass, getSalt()) . "', role=0;");
// FIXME: set the default role
// Send the new password to the user's email :
mail($_POST["email"], sprintf(_("Account created on https://%s"), $_SERVER["HTTP_HOST"]), sprintf(_("Hello,\nYour new account has just been created on https://%s\nPlease go there to login and change your password.\nYour login is %s\nand your password is %s\n\nThanks\n"), $_SERVER["HTTP_HOST"], $_REQUEST["login"], $pass));
$_REQUEST["msg"] = _("Account created successfully");
$_REQUEST["action"] = "";
}
break;
}
// SWITCH
require_once "head.php";
require_once "menu.php";
require "messagebox.php";
?>
<div class="container-fluid main">
开发者ID:vincib,项目名称:domainepublic,代码行数:30,代码来源:accounts.php
示例20: header
//$_SESSION['token'] = $results[SP::TOKEN];
$loggedIn = true;
break;
default:
// We don't care WHAT went wrong; this just means that the user's not logged in, which is all we need to know right now.
header("Location: logout.php?error=" . $results[SP::ERROR]);
break;
}
}
if ($loggedIn) {
// Already logged in
header("Location: profile.php");
exit;
}
$username = $_POST['username'];
$results = getSalt($db, $username);
switch ($results[SP::ERROR]) {
case ERR::OK:
$password = $_POST['password'];
$hash = hashPasswordCustomSalt($password, $results[LOGIN::SALT]);
$results = login($db, $username, $hash);
$loginToken = $results[SP::TOKEN];
switch ($results[SP::ERROR]) {
case ERR::OK:
$results = getUserID($db, $username);
switch ($results[SP::ERROR]) {
case ERR::OK:
$_SESSION['token'] = $loginToken;
$_SESSION['id'] = $results[USER::ID];
$_SESSION['permission'] = $results[PERMISSION::LEVEL];
header("Location: profile.php");
开发者ID:Blackdeathhh,项目名称:WDAAss2,代码行数:31,代码来源:newusersession.php
注:本文中的getSalt函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论