-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproba.php
50 lines (40 loc) · 1.16 KB
/
proba.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
<?php
function encrypt($sData, $sKey)
{
$sResult = '';
for($i = 0; $i < strlen($sData); $i ++)
{
$sChar = substr($sData, $i, 1);
$sKeyChar = substr($sKey, ($i % strlen($sKey)) - 1, 1);
$sChar = chr(ord($sChar) + ord($sKeyChar));
$sResult .= $sChar;
}
return encode_base64($sResult);
}
function decrypt($sData, $sKey)
{
$sResult = '';
$sData = decode_base64($sData);
for($i = 0; $i < strlen($sData); $i ++)
{
$sChar = substr($sData, $i, 1);
$sKeyChar = substr($sKey, ($i % strlen($sKey)) - 1, 1);
$sChar = chr(ord($sChar) - ord($sKeyChar));
$sResult .= $sChar;
}
return $sResult;
}
function encode_base64($sData)
{
$sBase64 = base64_encode($sData);
return strtr($sBase64, '+/', '-_');
}
function decode_base64($sData)
{
$sBase64 = strtr($sData, '-_', '+/');
return base64_decode($sBase64);
}
$enc=encode_base64("Most.Pravo.Simnuvanja-1");
echo "encrypt ".$enc."<br>";
echo "decrypt ".decode_base64($enc);
?>