-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmd5Hybrid.php
75 lines (48 loc) · 1.44 KB
/
md5Hybrid.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
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
echo md5Hybridx("rolly", 8);
function md5Hybridx($pass, $mcode_length){
//create mcode
$mcode = NonRepeatingRandomDigits($mcode_length);
echo $mcode." ";
//hash it
$pass_md5_hashed = md5($pass);
//compute chuncklenght
if((32 % 8) != 0) $chunklenght = ((int)(32/(8)))+1;
else $chunklenght = ((int)(32/(8)));
//split delimited the string
$delimited_hashed_code = chunk_split($pass_md5_hashed,$chunklenght);
/************************************************/
//remove all non printable characters
$str = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $delimited_hashed_code);
$str = rtrim($str);
//save it into array individualy
if(strpos($str, " ") !== false){
$str5 = explode(" ", $str);
}//if
$r = array();
for ($i = 0; $i < 8; $i++) {
$r[] = substr($mcode, $i, 1);
//echo $r[$i]."</br>";
}
//scramble it
$scrambledEgg = "";
for($j = 0; $j != 8; $j++){
for($i = 0; $i !=9; $i++){
if($r[$j] == $i){
$scrambledEgg .= $str5[$i]."--";
}
}
}//for j;
return $scrambledEgg;
}//
function NonRepeatingRandomDigits($length){
$numbers = range(0,$length-1);
shuffle($numbers);
$digits =0;
for($i = 0; $i < $length && $digits != 12 && $digits != 123 && $digits != 1234 && $digits != 12345 && $digits != 123456
&& $digits != 1234567 && $digits != 12345678; $i++){
global $digits;
$digits .= $numbers[$i];
}
return $digits;
}//