-
Notifications
You must be signed in to change notification settings - Fork 1
/
playground.php
62 lines (41 loc) · 1.54 KB
/
playground.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?
require_once 'functions.php';
verifyRequest($mysqli, $_POST);
//echo "request verified";
/*
$user = "gluse";
$device_id = "iphone34958";
$token = "73a6499ae8ad44fcbfbdca3dd6d15445";
$ret = hasValidToken($mysqli, $user, $device_id, $token);
echo "<br>hasvalidtoken:$ret";
*/
/*$user = sanitize('gluseppe');
$email = sanitize('giuseppe.frau@dblue.it');
$password = sanitize('123buona');
$role = "user";
//$password = "dblue4innovate";
$salt = bin2hex(openssl_random_pseudo_bytes(16));
echo "<br>salt: $salt";
$psw_salt = $password.$salt;
echo "<br>psw_salt: $psw_salt";
$salted_and_hashed = md5($psw_salt);
echo "<br>salted and hashed: $salted_and_hashed";
$ret = register($mysqli, $user, $email, $role, $salted_and_hashed, $salt);
$i_user = sanitize('gluseppe');
$device_id = sanitize('iphone123');
//recupera salt
$i_salt = db_getField($mysqli, 'user', 'salt', 'user', $i_user, true);
echo "<br>retrieved salt:$i_salt";
//$inserted_password = "dblue4innovate";
$inserted_password = sanitize('123buona');
//add salt to the inserted password
$i_psw_salted = $inserted_password.$i_salt;
echo "<br>inserted_and_salted:$i_psw_salted";
//hash the result. it will be compared with the entry in the db
$inserted_salted_and_hashed = md5($inserted_password.$i_salt);
echo "<br>inserted salted and hashed: $inserted_salted_and_hashed";
//retrieve entry from db
$salted_and_hashed_from_db = db_getField($mysqli, 'user', 'hash', 'user', $user, true);
echo "<br>salted and hashed from db: $salted_and_hashed_from_db";
*/
?>