Problems with encryption

0

Look, I have two projects, one next to the other and one runs perfectly and the other does not. look at the codes:

<?php 
    $opciones = [
    'cost' => 11,
    'salt' => "ÑsodEFHbzvuQlIwtvHgVsCsFbaUdjpwsHxwvHBcppgyveqUksQb37695202931484987193162641539158212389566725204804!!·$%&/()=?¿^*Ǩ_:;>|@#¢∞¬÷“”≠´‚[]{}–…„≤<ñ",
];
echo password_hash("ADMIN", PASSWORD_BCRYPT, $opciones)."\n";
?>

in this it works perfectly and the result is:

but if I do it in my complete project as follows:

<?php

function claveEncrypt($clave)
{
    $opciones = [
    'cost' => 11,
    'salt' => "ÑsodEFHbzvuQlIwtvHgVsCsFbaUdjpwsHxwvHBcppgyveqUksQb37695202931484987193162641539158212389566725204804!!·$%&/()=?¿^*Ǩ_:;>|@#¢∞¬÷“”≠´‚[]{}–…„≤<ñ"
];
echo password_hash($clave, PASSWORD_BCRYPT, $opciones)."\n";
}

and I call her as follows:

<?php
    include "../../utilities/functions.php";
    $link = mysqli_connect("localhost", "user", "clave");
    mysqli_select_db($link, "bd");
    $tildes = $link->query("SET NAMES 'utf8'"); //Para que se muestren las tildes correctamente
    $username=$_POST['username'];
    $clave = claveEncrypt($_POST['password']);
    echo $clave;
    die;
    $result = mysqli_query($link, "SELECT * FROM users WHERE username='$username' AND password='$password'");
    if ($fila = mysqli_fetch_array($result)){
        session_start();
        if(isset($_POST['remember'])){
            //setcookie ("nickname",$use, time()+60);
            ini_set('session.cookie_lifetime', 60 * 60 * 24 * 30);
            session_regenerate_id(TRUE);
        }
        $_SESSION['nickname']= $username;
        header('Location: ../../views/administrator/home.iq');
    }else {
        header('Location: ../../views/administrator/admin.html');
    }
?>

and the result is:

Does anyone know what I'm doing wrong?

    
asked by Andrés Vélez 23.11.2018 в 17:57
source

0 answers