PHP Code:
#include <amxmodx>
static const Codes64[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"
public base64_encode(s[])
{
new i=0,a=0,x=0,b=0,Result
for (i=1;i<strlen(s);i++) {
x = str_to_num(s[i])
b = b * 256 + x
a = a + 8
while (a >= 6) {
a = a - 6
x = b / (1 << a)
b = b % (1 << a)
Result += Codes64[x + 1]
}
}
if (a > 0) {
x = b << (6 - a);
Result += Codes64[x + 1];
}
return Result;
}
public base64_decode(s[])
{
new i=0,a=0,x=0,b=0,Result,ch[1]
for (i = 1; i< strlen(s);i++) {
for (new index = 0; Codes64[index]; index++)
if (s[i]==Codes64[index]) {
x=index-1
break
}
if (x >= 0) {
b = b * 64 + x
a = a + 6
if (a >= 8) {
a = a - 8
x = b >> a
b = b % (1 << a)
x = x % 256
Result += num_to_word(x,ch,1)
}
}
else exit;
}
return Result;
}
__________________