本文整理汇总了PHP中openssl_digest函数的典型用法代码示例。如果您正苦于以下问题:PHP openssl_digest函数的具体用法?PHP openssl_digest怎么用?PHP openssl_digest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了openssl_digest函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _digestOpenssl
protected static function _digestOpenssl($algorithm, $data, $binaryOutput)
{
if ($algorithm == 'ripemd160') {
$algorithm = 'rmd160';
}
return openssl_digest($data, $algorithm, $binaryOutput);
}
示例2: makeHash
function makeHash($data, $alg)
{
// $s = hash_hmac('sha256', $data, 'secret', true);
// return base64_encode($s);
$ret = openssl_digest($data, $alg);
return $ret;
}
示例3: digest
/**
* @param string $data
* @param string $algorithm
*
* @return Hash
*/
public static function digest(string $data, string $algorithm) : Hash
{
$hash = new Hash();
$hash->setAlgorithm($algorithm);
$hash->setValue(openssl_digest($data, $algorithm, TRUE));
return $hash;
}
示例4: compute
private function compute($data)
{
switch ($this->getFavorite()) {
case 'openssl':
return sprintf('%s-%s', $this->type, base64_encode(openssl_digest($data, $this->type, true)));
case 'hash':
return sprintf('%s-%s', $this->type, base64_encode(hash($this->type, $data, true)));
}
throw new \RuntimeException('No hash function on this platform');
}
示例5: alta_tutor_inAction
public function alta_tutor_inAction()
{
$request = $this->getRequest();
$session = $request->getSession();
$dni = $request->request->get('dni');
$Miusuario = $this->getDoctrine()->getRepository('tutoriasBundle:Persona')->findOneByDni($dni);
$cant = sizeof($Miusuario);
if ($cant == 0) {
if ($this->VerificoPerfil('alta_tutor')) {
$persona = new Persona();
$nombre = $request->request->get('nombre');
$apellido = $request->request->get('apellido');
$legajo = $request->request->get('legajo');
$email = $request->request->get('email');
$persona->setNombre($nombre);
$persona->setApellido($apellido);
$persona->setLegajo($legajo);
$persona->setEmail($email);
$persona->setActivo(1);
$password = $request->request->get('password');
$em = $this->getDoctrine()->getManager();
$salCodifided = openssl_random_pseudo_bytes(32);
//$sal = (string)$sal;
//$sal =rand(5, 15);
$sal = utf8_encode($salCodifided);
$hash = openssl_digest($password . $sal, 'sha512');
$dni = $request->request->get('dni');
$perfil = $this->getDoctrine()->getRepository("tutoriasBundle:Perfil")->findOneBydescripcion('Tutor');
$persona->setIdperfil($perfil->getIdperfil());
$persona->setDni($dni);
$persona->setSal($sal);
$persona->setHash($hash);
$em->persist($persona);
$em->flush();
$tutor = new Tutor();
$tutor->setIdpersona($persona->getIdpersona());
$em->persist($tutor);
$em->flush();
$session->set('mensaje_session', 'Alta de Tutor Exitosa!');
//return $this->redirectToRoute('tutorias_alta_tutor', array('usuario'=>$session->get('Usuario'),'estado'=>'ok','perfil'=>$session->get('perfil'),'tipo'=>$session->get('tipo')), 301);
return $this->redirectToRoute('tutorias_show_tutor');
} else {
return $this->redirectToRoute('tutorias_login', array('mensaje' => '', 'tipo' => ''), 301);
}
} else {
#en el caso de que ya exista el usuario con ese DNi se redirige
$mensaje = "Ya existe un usuario con el mismo DNI ,por favor ingrese los datos nuevamente";
return $this->alta_tutor($mensaje);
}
}
示例6: podlove_handle_media_file_tracking
function podlove_handle_media_file_tracking(\Podlove\Model\MediaFile $media_file)
{
if (\Podlove\get_setting('tracking', 'mode') !== "ptm_analytics") {
return;
}
if (strtoupper($_SERVER['REQUEST_METHOD']) === 'HEAD') {
return;
}
$intent = new Model\DownloadIntent();
$intent->media_file_id = $media_file->id;
$intent->accessed_at = date('Y-m-d H:i:s');
$ptm_source = trim(podlove_get_query_var('ptm_source'));
$ptm_context = trim(podlove_get_query_var('ptm_context'));
if ($ptm_source) {
$intent->source = $ptm_source;
}
if ($ptm_context) {
$intent->context = $ptm_context;
}
// set user agent
$ua_string = trim($_SERVER['HTTP_USER_AGENT']);
if ($agent = Model\UserAgent::find_or_create_by_uastring($ua_string)) {
$intent->user_agent_id = $agent->id;
}
// save HTTP range header
// @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35 for spec
if (isset($_SERVER['HTTP_RANGE'])) {
$intent->httprange = $_SERVER['HTTP_RANGE'];
}
// get ip, but don't store it
$ip_string = $_SERVER['REMOTE_ADDR'];
try {
$ip = IP\Address::factory($_SERVER['REMOTE_ADDR']);
if (method_exists($ip, 'as_IPv6_address')) {
$ip = $ip->as_IPv6_address();
}
$ip_string = $ip->format(IP\Address::FORMAT_COMPACT);
} catch (\InvalidArgumentException $e) {
\Podlove\Log::get()->addWarning('Could not use IP "' . $_SERVER['REMOTE_ADDR'] . '"' . $e->getMessage());
}
// Generate a hash from IP address and UserAgent so we can identify
// identical requests without storing an IP address.
if (function_exists('openssl_digest')) {
$intent->request_id = openssl_digest($ip_string . $ua_string, 'sha256');
} else {
$intent->request_id = sha1($ip_string . $ua_string);
}
$intent = $intent->add_geo_data($ip_string);
$intent->save();
}
示例7: _aesEncrypt
/**
* Encrypt data using AES-256-CBC and the key provided as a parameter.
*
* @param string $data The data to encrypt.
* @param string $secret The secret to use to encrypt the data.
*
* @return string The IV and encrypted data concatenated.
* @throws \InvalidArgumentException If $data is not a string.
* @throws \SimpleSAML_Error_Exception If the openssl module is not loaded.
*
* @see \SimpleSAML\Utils\Crypto::aesEncrypt()
*/
private static function _aesEncrypt($data, $secret)
{
if (!is_string($data)) {
throw new \InvalidArgumentException('Input parameter "$data" must be a string.');
}
if (!function_exists("openssl_encrypt")) {
throw new \SimpleSAML_Error_Exception('The openssl PHP module is not loaded.');
}
$raw = defined('OPENSSL_RAW_DATA') ? OPENSSL_RAW_DATA : true;
$key = openssl_digest($secret, 'sha256');
$method = 'AES-256-CBC';
$ivSize = 16;
$iv = substr($key, 0, $ivSize);
return $iv . openssl_encrypt($data, $method, $key, $raw, $iv);
}
示例8: verify_message
public function verify_message($id = '', $data = '')
{
if ($id == '') {
return 0;
}
$q = $this->db->query("SELECT `size`, `hlen`, `digest`, `bodydigest`,`attachments` FROM " . TABLE_META . " WHERE piler_id=?", array($id));
$digest = $q->row['digest'];
$bodydigest = $q->row['bodydigest'];
$size = $q->row['size'];
$hlen = $q->row['hlen'];
$attachments = $q->row['attachments'];
$_digest = openssl_digest($data, "SHA256");
$_bodydigest = openssl_digest(substr($data, $hlen), "SHA256");
if ($_digest == $digest && $_bodydigest == $bodydigest) {
return 1;
}
return 0;
}
示例9: alta_tutor_inAction
public function alta_tutor_inAction()
{
$request = $this->getRequest();
$session = $request->getSession();
$dni = $request->request->get('dni');
$Miusuario = $this->getDoctrine()->getRepository('tutoriasBundle:Persona')->findOneByDni($dni);
if ($Miusuario = '') {
if ($this->VerificoPerfil('alta_tutor')) {
$persona = new Persona();
$nombre = $request->request->get('nombre');
$apellido = $request->request->get('apellido');
$legajo = $request->request->get('legajo');
$email = $request->request->get('email');
$persona->setNombre($nombre);
$persona->setApellido($apellido);
$persona->setLegajo($legajo);
$persona->setEmail($email);
$persona->setActivo(1);
$password = $request->request->get('password');
$em = $this->getDoctrine()->getManager();
$salCodifided = openssl_random_pseudo_bytes(32);
//$sal = (string)$sal;
//$sal =rand(5, 15);
$sal = utf8_encode($salCodifided);
$hash = openssl_digest($password . $sal, 'sha512');
$dni = $request->request->get('dni');
$perfil = $this->getDoctrine()->getRepository("tutoriasBundle:Perfil")->findOneBydescripcion('Tutor');
$persona->setIdperfil($perfil->getIdperfil());
$persona->setDni($dni);
$persona->setSal($sal);
$persona->setHash($hash);
$em->persist($persona);
$em->flush();
$tutor = new Tutor();
$tutor->setIdpersona($persona->getIdpersona());
$em->persist($tutor);
$em->flush();
return $this->redirectToRoute('tutorias_alta_tutor', array('usuario' => $session->get('Usuario'), 'estado' => 'ok', 'perfil' => $session->get('perfil'), 'tipo' => $session->get('tipo')), 301);
} else {
return $this->redirectToRoute('tutorias_alta_tutor', array('usuario' => $session->get('Usuario'), 'estado' => 'ok', 'perfil' => $session->get('perfil'), 'tipo' => $session->get('tipo'), 'result' => $result), 301);
}
}
}
示例10: dataBase
$dataBase = new dataBase();
if (isset($_POST["changeInfo"])) {
$newEmail = $_POST["email"];
$id = $_POST["id"];
if ($_POST["email"] != "" && $_FILES["profilePicture"]["name"] != "") {
if ($_FILES["profilePicture"]["type"] == "image/png" || $_FILES["profilePicture"]["type"] == "image/jpeg" || $_FILES["profilePicture"]["type"] == "image/gif") {
if ($_FILES["profilePicture"]["size"] <= 2000000) {
$newPictureName = newName($_FILES["profilePicture"]["name"]);
while (file_exists("img\\" . $newPictureName)) {
$newPictureName = newName($_FILES["profilePicture"]["name"]);
}
move_uploaded_file($_FILES['profilePicture']['tmp_name'], "img\\" . $newPictureName);
$test = $dataBase->update("users", "email", "'" . $newEmail . "'", "profile_picture", "'" . $newPictureName . "'", "id", "'" . $id . "'");
$salt = $dataBase->getRow("salt", "users", true, "'" . $id . "'", "id");
$actualSalt = $salt[0]["salt"];
$hash = openssl_digest($newEmail . $actualSalt, 'sha512');
var_dump($test);
setcookie("login", $newEmail . "," . $hash, time() + 2592000);
header("location: gegevens-wijzigen-form.php");
} else {
$_SESSION["notifications"]["type"] = "error";
$_SESSION["notifications"]["message"] = "File is too big";
header("location: gegevens-wijzigen-form.php");
}
} else {
$_SESSION["notifications"]["type"] = "error";
$_SESSION["notifications"]["message"] = "File is wrong type";
header("location: gegevens-wijzigen-form.php");
}
} else {
$_SESSION["notifications"]["type"] = "error";
示例11: ripe160
/**
* Returns a RIPDEMD160 hash of a value.
*
* @param string $data
*
* @return string
*/
public static function ripe160($data, $binary = false)
{
return openssl_digest($data, 'ripemd160', $binary);
}
示例12: array
$checkPasswordQuery = ' SELECT hashed_password, salt FROM users
WHERE email = :email
';
$checkPasswordStatement = $db->prepare($checkPasswordQuery);
$checkPasswordStatement->bindValue(':email', $email);
$checkPasswordStatement->execute();
$passwordSaltedArray = array();
while ($row = $checkPasswordStatement->fetch(PDO::FETCH_ASSOC)) {
$passwordSaltedArray[] = $row;
}
$passwordToCheck = openssl_digest($password . $passwordSaltedArray[0]['salt'], 'sha512');
$originalPassword = $passwordSaltedArray[0]['hashed_password'];
if ($passwordToCheck == $originalPassword) {
unset($_SESSION['login']);
//hash the email + password that is salted with name 'salt'
$hashedEmailSalt = openssl_digest($email . $passwordSaltedArray[0]['salt'], 'sha512');
setcookie('login', $email . ',' . $hashedEmailSalt, time() + 2592000);
//30days
setcookie('email', $email, time() + 2592000);
header('location: dashboard.php');
} else {
$_SESSION['message']['type'] = 'error';
$_SESSION['message']['text'] = 'password is wrong';
header('location: login-form.php');
}
}
} catch (PDOException $e) {
$messageContainer = 'ERROR ERROR ERROR: ' . $e;
}
}
?>
示例13: mysql_connect
<?php
require "tt_config.php";
$conn = mysql_connect($myserver_name, $myserver_username, $myserver_password);
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db($myserver_database, $conn);
#$strsql="select * from `tb_todolist`";
$filename = "./add_user.json";
$handle = fopen($filename, "r");
$content = fread($handle, filesize($filename));
#print $content;
$useradd = json_decode($content);
print $useradd->{'user_name'};
print $useradd->{'user_passwd'};
$sqlstr = "INSERT INTO tb_user (user_name,user_passwd) VALUES (" . "'" . $useradd->{'user_name'} . "'" . ',' . "'" . openssl_digest($useradd->{'user_passwd'}, 'sha512') . "'" . ")";
echo $sqlstr;
mysql_query($sqlstr);
mysql_error();
mysql_close($conn);
示例14: explode
if (isset($_COOKIE["login"])) {
$userInformation = explode(',', $_COOKIE["login"]);
$email = $userInformation[0];
$cookieString = $userInformation[1];
$validationComplete = false;
$db = new PDO('mysql:host=localhost;dbname=opdracht_file_upload', 'root', 'root');
$cookieCheck = "SELECT salt from users where email = :email";
$cookieCheckStatement = $db->prepare($cookieCheck);
$cookieCheckStatement->bindParam(":email", $userInformation[0]);
$cookieCheckStatement->execute();
$saltAr = array();
while ($row = $cookieCheckStatement->fetch(PDO::FETCH_ASSOC)) {
$saltAr[] = $row;
}
$salt = $saltAr[0]["salt"];
$toCheckCookieString = openssl_digest($email . $salt, 'sha512');
if ($toCheckCookieString == $cookieString) {
$validationComplete = true;
} else {
setcookie("login", null, -1);
$_SESSION["notifications"]["type"] = "error";
$_SESSION["notifications"]["message"] = "Something went wrong with your validation, please contact the webmaster";
}
} else {
$_SESSION["notifications"]["type"] = "error";
$_SESSION["notifications"]["message"] = "You are not logged in yet, please do";
header("location: login-form.php");
}
if (isset($_GET["logout"])) {
setcookie("login", null, -1);
$_SESSION["notifications"]["type"] = "notifications";
示例15: mysqli_escape_string
<?php
// session utils
include 'sessions.php';
// open connection to the database
include 'config.php';
include 'readDB.php';
include 'writeDB.php';
$salt = 'salt$';
// get POST information from login form
$email = mysqli_escape_string($read, $_POST["email"]);
$password = mysqli_escape_string($read, $_POST["password"]);
//Hash the password
$password = openssl_digest($password . $salt, 'sha512');
//Prepare the sequel query and bind parameters
$stmt = $read->prepare('SELECT email, password FROM users WHERE email = ? AND password = ?');
$stmt->bind_param('ss', $email, $password);
//Retrieves data from user table
if (!$stmt->execute()) {
header('Location: /login.php?message=Login%20Failed');
die;
}
$stmt->store_result();
//Check if the password was correct
if ($stmt->num_rows()) {
//Set session data
$_SESSION['user'] = $email;
$_SESSION['id'] = authenticated_session($email);
header('Location: /index.php');
} else {
// logout