当前位置: 首页>>代码示例>>PHP>>正文


PHP Encryption::generateSalt方法代码示例

本文整理汇总了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>
开发者ID:Carlgo11,项目名称:Encryption,代码行数:25,代码来源:index.php

示例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`=?");
开发者ID:alijaffar,项目名称:UploadMe,代码行数:31,代码来源:upload_file.php


注:本文中的Encryption::generateSalt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。