-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathHTML_Encrypt.php
More file actions
61 lines (55 loc) · 1.41 KB
/
Copy pathHTML_Encrypt.php
File metadata and controls
61 lines (55 loc) · 1.41 KB
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
<?php
/**
* Class HTML_Encrypt
*
* @author Tayfun Erbilen
* @web http://www.erbilen.net
* @mail tayfunerbilen@gmail.com
*/
class HTML_Encrypt
{
/**
* @param $str
* @param int $len
* @return array
*
* Kelimeyi utf8 karakterlerine uygun olarak parçalar.
*/
public static function utf8_split($str, $len = 1)
{
$arr = array();
$strLen = mb_strlen($str, 'UTF-8');
for ($i = 0; $i < $strLen; $i++) {
$arr[] = mb_substr($str, $i, $len, 'UTF-8');
}
return $arr;
}
/**
* @param $character
* @return mixed
*
* Her karakterin utf8'e uygun ASCII değerini döndürür.
*/
public static function utf8_ord( $character )
{
list(, $ord) = unpack('N', mb_convert_encoding($character, 'UCS-4BE', 'UTF-8'));
return $ord;
}
/**
* @param $html
* @return string
*
* Onluk sayı sisteminin onaltılık sayı sistemine dönüştürülmesi.
*/
public static function encrypt( $html )
{
$html = str_replace(array("\n","\r","\t"), ' ', $html);
$hex = '<script type="text/javascript">document.write(unescape("';
$characters = self::utf8_split($html);
foreach ( $characters as $character ){
$hex .= '%' . dechex(self::utf8_ord($character));
}
$hex .= '"));</script>';
return $hex;
}
}