-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombfunc_giver.php
67 lines (32 loc) · 1.38 KB
/
combfunc_giver.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
<?php
class CFuncGiver {
protected $gived_funcs; //assoc arr
function __construct() {
$this->gived_funcs = [];
$this->gived_funcs['test'] = [$this, 'testone'];
$this->gived_funcs['produced_combinations'] = [$this, 'get_produced_combinations'];
}
function give_func($fname) {
return $this->gived_funcs[$fname];
}
function testone($param) { //param - string
return "test" . $param;
} //test
function get_produced_combinations($CG, $ids) {
echo "DEBUG: in the outer function get_produced_combinations \n";
$combinations = [];
//$combinations = array_merge($combinations, $ids);
foreach ($ids as $id) {
//echo $id[0] ."\n";
$hashed_id = hash('sha256', $id[0]); //this is a 2 dim arr
$gmp_hashed_id = gmp_init($hashed_id, 16);
$comb_id = $CG->wcomb_gmp_number2str($gmp_hashed_id);
if (strlen($comb_id) < $CG->get_comb_size()) throw new Exception("not enough characters in hash.");
//$cur_prod_comb = substr($comb_id, -$CG->get_comb_size()); //deprecated
$cur_prod_comb = substr($comb_id, 0, $CG->get_comb_size());
array_push($combinations, [$id[0], $cur_prod_comb]); //$id is array
}
return $combinations;
} //get_produced_combinations
} //CFuncGiver class
?>