@parzibyte/

OpenCart password reset

PHP (Legacy)

No description

fork
loading
main.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
#<?php
function token($length = 32) {
	// Create random token
	$string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
	
	$max = strlen($string) - 1;
	
	$token = '';
	
	for ($i = 0; $i < $length; $i++) {
		$token .= $string[mt_rand(0, $max)];
	}	
	
	return $token;
}

function generar_pass($passTextoPlano){
	$sal = token(9);
	$hash = sha1($sal . sha1($sal . sha1($passTextoPlano)));
	return [
		"sal" => $sal,
		"hash" => $hash,
	];
}

// Demostrar uso
$datosPass = generar_pass("hunter2");
$pass = $datosPass["hash"]; // Este va en el campo password
$sal = $datosPass["sal"]; // Este va en el campo salt
printf("La sal es %s y la pass es %s", $sal, $pass);
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7