Jump to content
Xander

Logare pe baza de amprenta

Recommended Posts

Posted (edited)

Este doar un poc dar oricum fata de

[RST] Autentificare pe baza de "amprenta"

care nu poate fi folosit IRL... metoda asta (salvezi hash-ul fisierului doar in db)

este mult mai eficienta si ca timp de executie si ca memorie

+ merge cu orice tip de fisier(poze,arhive,virusi, etc...)



<?php
session_start();
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="upl" />
<input type="submit" name="submit" value="Verifica" />
</form>
<?php
if(isset($_POST['submit']))
{
$data = file_get_contents($_FILES['upl']['tmp_name']);
$hash = hash('sha512', $data);
unset($_FILES['upl']['tmp_name']);
if(!isset($_SESSION['ok']) && $data != "")
{
$good_hash = trim(file_get_contents(".hthash"));
if(!isset($_FILES['upl']) || $_FILES['upl']['error'])
die("Error please choose a file!");
if($hash != $good_hash)
die("Invalid!");
$_SESSION['ok'] = 1;
}
else
{
file_put_contents(".hthash" , $hash);
echo "Hash updated, session destroyed!<br />";
unset($_SESSION['ok']);
die();
}
echo "Welcome home, upload a file to change the signature.";
}
?>

p.s. daca vreti sa testati scriptul asa cum este trebuie sa aveti drept de scriere pe fisierul .hthash

Edited by Xander

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...