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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
| function pershash($str){
$id_table = array();
$operations;
$base = 0;
$flashs = array();
$hash;
$reallenght = strlen($str);
if(isset($str) &&$reallenght>0 && $str !=""){
for($i=0 ; $i<$reallenght ; $i++ ){
$id_table[] = ord($str[$i]);
}
for($i=$reallenght ; $i<19 ; $i++ ){
$id_table[$i] = floor(($id_table[$i-1]*M_SQRTPI)/M_SQRT3)+4;
}
$j = 0;
foreach($id_table as $id){
if(is_int($j/3)){
$base += $j-$id;
}else if(is_int($j/2)){
$base += $j+$id;
}else{
$base -= $j+$id;
}
$j++;
}
$operations = 10000 *(M_PI / M_E)+$base;
$j = 0;
$nbr_ids = floor(count($id_table)/19);
foreach($id_table as $id){
if(is_int($id/55)){
$operations -= asinh (intval($id));
}
else if(is_int($id/27)){
$operations *= sqrt((intval($id)*0.01)/ M_LOG10E);
}
else if(is_int($id/13)){
$operations /= round(intval($id)/ M_LN10)+M_EULER;
}
else if(is_int($id/9)){
$operations -= M_PI+intval($id);
$operations += 951;
}
else if(is_int($id/7)){
$operations *= M_LNPI;
$operations -= 456;
}
else if(is_int($id/4)){
$operations -= round(intval($id)-44.7,8);
$operations *= round(M_PI_2,5);
}
else if(is_int($id/3)){
$operations /= intval($id)+3.77;
}
else if(is_int($id/2)){
$operations += atan2(intval($id),(intval($id)/2)-M_SQRTPI);
}
else{
$operations -= sin(intval($id));
}
$totest = intval($j)/intval($nbr_ids);
if(is_int($totest)){
$operations -= $id;
$flashs[] = $operations;
$operations /= $operations -0.9;
}
$j++;
}
$flashs[] = $operations-$id;
$interm_hash="";
$j = 0;
foreach($flashs as $flash){
$flash = str_replace (".","" , $flash."");
$flash = str_replace ("-","" , $flash."");
if(is_int($j/2)){
$flash -= $reallenght;
}else{
$flash -= $base;
}
$flash .= "";
$flash_temp = "";
$flash_temp2 = "";
for($i=0 ; $i<16 ; $i++ ){
if(isset($flash[$i])){
if(is_int($i/2)){
$flash_temp .= $flash[$i];
}else{
$flash_temp2 .= $flash[$i];
}
}
}
$flash_temp = intval($flash_temp);
$flash_temp2 = intval($flash_temp2);
if(is_int($j/3)){
$interm_hash.=intval($flash_temp).intval($flash_temp2);
}else if(is_int($j/2)){
$interm_hash.=intval($flash_temp2).intval($flash_temp);
}else{
$interm_hash=intval($flash_temp).intval($flash_temp2).$interm_hash;
}
$j++;
}
if(is_int($base/5)){
$interm_hash=substr($interm_hash,102).substr($interm_hash,0, 102);
}else if(is_int($base/3)){
$interm_hash=substr($interm_hash,97).substr($interm_hash,0, 97);
}else if(is_int($base/2)){
$interm_hash=substr($interm_hash,37).substr($interm_hash,0, 37);
}else{
$interm_hash=substr($interm_hash, 3 ).substr($interm_hash, 0 , 2);
}
$hash = "";
for($i = 0 ; $i < strlen(strval($interm_hash))-8 ; $i+=8){
$hash .= dechex(intval($interm_hash[$i].$interm_hash[$i+1].$interm_hash[$i+2].$interm_hash[$i+3].$interm_hash[$i+4].$interm_hash[$i+5].$interm_hash[$i+6].$interm_hash[$i+7]));
}
return $hash;
}else{
return false;
}
} |