Skip to content

Commit a8d7fbd

Browse files
committed
first commit
0 parents  commit a8d7fbd

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

class.MailEncrypt.php

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
/*
4+
* Copyright (C) 2018
5+
* Julien Winant (http://github.com/harkor)
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
/*
22+
23+
Example
24+
echo (new MailEncrypt('<a href="mailto:[email protected]">[email protected]</a>'))->get();
25+
26+
*/
27+
28+
class MailEncrypt {
29+
30+
private $string = "";
31+
private $key = 6;
32+
33+
public function __construct($string){
34+
$this->string = $string;
35+
}
36+
37+
private function encryptString(){
38+
39+
$chars = str_split($this->string, 1);
40+
41+
$output = '';
42+
foreach($chars as $char):
43+
$output .= chr(($this->key ^ ord($char)));
44+
endforeach;
45+
46+
return $output;
47+
48+
}
49+
50+
private function getJavaScript($string){
51+
52+
$myVar = 'a'.md5(random_bytes(15)+time()+random_bytes(15));
53+
54+
$result = '<script language="JavaScript">
55+
<!--
56+
var '.$myVar.'_enc= \''.$string.'\';
57+
for('.$myVar.'_i=0;'.$myVar.'_i<'.$myVar.'_enc.length;++'.$myVar.'_i)
58+
{
59+
document.write(String.fromCharCode('.$this->key.'^'.$myVar.'_enc.charCodeAt('.$myVar.'_i)));
60+
}
61+
//-->
62+
</script>';
63+
64+
return $result;
65+
66+
}
67+
68+
public function get(){
69+
70+
return $this->getJavaScript($this->encryptString());
71+
72+
}
73+
74+
}

0 commit comments

Comments
 (0)