本文整理汇总了PHP中Encryption::generateSalt方法的典型用法代码示例。如果您正苦于以下问题:PHP Encryption::generateSalt方法的具体用法?PHP Encryption::generateSalt怎么用?PHP Encryption::generateSalt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encryption
的用法示例。
在下文中一共展示了Encryption::generateSalt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Example page</title>
</head>
<body>
<h2>This is an example page</h2>
<h4>Look at the source code for this page if you want to learn how to use the Auth lib.</h4>
<?php
include_once 'lib/Auth/Encryption.php';
include_once 'lib/Auth/Config.php';
$salt = Encryption::generateSalt("hashing");
$encrypted = Encryption::generateHash("asd", $salt);
echo "Hashed: " . $encrypted . "<br>";
$verify = Encryption::verifyHash("asd" . $salt, $encrypted);
echo "Verified: ";
if ($verify == true) {
echo "true";
} elseif ($verify == false) {
echo "false";
}
?>
</body>
</html>
示例2: explode
}
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
$filename = $_FILES['file']['name'];
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
} else {
$tmpName = $_FILES['file']['tmp_name'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
$password = NULL;
if ($_POST['password'] != "") {
include 'lib/Encryption.php';
$salt = Encryption::generateSalt();
$content = Encryption::encrypt($content, $_POST['password'], $salt);
$password = $_POST['password'];
$filename = Encryption::encrypt($filename, $_POST['password'], $salt);
}
$name = getName(10, 20, "name") . "." . $extension;
$rmcode = getName(32, 64, "removalcode");
$options = array('cost' => 12);
require __DIR__ . "/lib/password.php";
$hashrmcode = password_hash($rmcode, PASSWORD_BCRYPT, $options);
$q = "INSERT INTO `" . $config['mysql-table'] . "` (`name`, `size`, `type`, `content`, `file-name`, `removalcode`) VALUES (?, ?, ?, ?, ?, ?);";
$query = $database->prepare($q);
$query->bind_param("ssssss", $name, $_FILES['file']['size'], $_FILES['file']['type'], $content, $filename, $hashrmcode);
$query->execute();
if ($_POST['password'] != "") {
$m = $database->prepare("UPDATE `" . $config['mysql-table'] . "` SET `salt`=?, `encryption`=? WHERE `name`=?");