Jump to content


Photo

Base64 Dll


  • Please log in to reply
18 replies to this topic

#1 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 19 April 2009 - 12:07 AM

I saw a request for a Base64 DLL, and I thought, "I'll make one!" (and I needed one for my current project).

So I made one.

This zip contains the example and the dll. Post your comments and suggestions here.

TEH LINK

Please give credit!!

PS: This is my FIRST DLL!
  • 0

#2 Grundoko

Grundoko

    GMC Member

  • GMC Member
  • 566 posts

Posted 19 April 2009 - 07:04 AM

What does it do?
It almost seems like Encryption
  • 0

#3 death-droid

death-droid

    GMC Member

  • GMC Member
  • 2600 posts

Posted 19 April 2009 - 07:13 AM

GSoft that's exactly what it is.
  • 0

#4 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 19 April 2009 - 02:54 PM

Base64 is not encryption. It was developed as a way to send binary data over plain text protocols. (Mime)

As many people explained before,

Wikipedia
  • 0

#5 Hockeyflyers

Hockeyflyers

    Hockeyplayer Games

  • New Member
  • 1108 posts
  • Version:Unknown

Posted 19 April 2009 - 04:04 PM

I think this has been done with a script.

I found it after checking through my script collection, actually, I found two. One of them doesn't work (I dont think)...

var out, char, ref, len, i, j;
ref = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrst
uvwxyz0123456789+/";
len = string_length(argument0);
i = 0;
out = "";
while (i < (len div 3)*3) {
  j = 0;
  while (j < 3) {
	char[j] = ord(string_copy(argument0,i+1,1)); // string_char_at works too, string_copy is just less typing
	i += 1;  j += 1;
  }
  out += string_copy(ref,(char[0] >> 2) + 1,1);
  out += string_copy(ref,(((char[0] & 3) << 4) | (char[1] >> 4)) + 1,1);
  out += string_copy(ref,(((char[1] & 15) << 2) | (char[2] >> 6)) + 1,1);
  out += string_copy(ref,(char[2] & 63) + 1,1);
}
if (len mod 3 == 2) {
  char[0] = ord(string_copy(argument0,i+1,1));
  char[1] = ord(string_copy(argument0,i+2,1));
  out += string_copy(ref,(char[0] >> 2) + 1,1);
  out += string_copy(ref,(((char[0] & 3) << 4) | (char[1] >> 4)) + 1,1);
  out += string_copy(ref,((char[1] & 15) << 2) + 1,1) + '=';
}
else if (len mod 3 == 1) {
  char[0] = ord(string_copy(argument0,i+1,1));
  out += string_copy(ref,(char[0] >> 2) + 1,1) + string_copy(ref,((char[0] & 3) << 4) + 1,1) + '==';
}
return out;

OR

var len;
len=argument0;

var base64_table;
base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrst
uvwxyz0123456789+/";

var X,Y,i,flag,m,n;
Y=0;
flag=0;
m=0;
n = 3;

var triple,quad,c;
triple[3]="";
quad[4]="";
c="";

var encode;
encode[1024]=0; 

var dst,src;

for(X = 0; X < len; X = X + 3) 
{ 
  if((len - X) / 3 == 0) n = (len - X) mod 3;
	 
  for(i=0; i < 3; i+=1) triple[i] = '0'; 
  for(i=0; i < n; i+=1) triple[i] = src[X + i]; 
  quad[0] = base64_table[(triple[0] & $FC) >> 2]; // FC = 11111100 
  quad[1] = base64_table[((triple[0] & $03) << 4) | ((triple[1] & $F0) >> 4)]; // 03 = 11 
  quad[2] = base64_table[((triple[1] & $0F) << 2) | ((triple[2] & $C0) >> 6)]; // 0F = 1111, C0=11110 
  quad[3] = base64_table[triple[2] & $3F]; // 3F = 111111 
  if(n < 3) quad[3] = '='; 
  if(n < 2) quad[2] = '='; 
  for(i=0; i < 4; i+=1) dst[X + i] = quad[i]; 
  Y = Y + 4; 
  m = m + 4; 
  if((m != 0)&&((m mod MAXLINE) == 0)) 
  { 
	dst[Y] = '\r'; 
	dst[Y+1] = '\n'; 
	flag+=1; 
	Y += 2; 
	m = 0; 
  } 
} 
dst[Y] = '\0'; 
return encode;

Please note I didn't write the above two scripts, I forget who originally wrote them.

Also, I made an escape script:
argument0=string_replace_all(argument0,"%","|%%&^%$&^}{:)(**_**%(^#");
if argument1==true
{
  argument0=string_replace_all(argument0,"1","\A||%%&^%$&^}{:)(**_**%(^#");
  argument0=string_replace_all(argument0,"2","\B||%%&^%$&^}{:)(**_**%(^#");
  argument0=string_replace_all(argument0,"3","\C||%%&^%$&^}{:)(**_**%(^#");
  argument0=string_replace_all(argument0,"4","\D||%%&^%$&^}{:)(**_**%(^#");
  argument0=string_replace_all(argument0,"5","\E||%%&^%$&^}{:)(**_**%(^#");
  argument0=string_replace_all(argument0,"6","\F||%%&^%$&^}{:)(**_**%(^#");
  argument0=string_replace_all(argument0,"7","\G||%%&^%$&^}{:)(**_**%(^#");
  argument0=string_replace_all(argument0,"8","\H||%%&^%$&^}{:)(**_**%(^#");
  argument0=string_replace_all(argument0,"9","\I||%%&^%$&^}{:)(**_**%(^#");
  argument0=string_replace_all(argument0,"0","\J||%%&^%$&^}{:)(**_**%(^#");

  argument0=string_replace_all(argument0,"\A||%%&^%$&^}{:)(**_**%(^#","%31");
  argument0=string_replace_all(argument0,"\B||%%&^%$&^}{:)(**_**%(^#","%32");
  argument0=string_replace_all(argument0,"\C||%%&^%$&^}{:)(**_**%(^#","%33");
  argument0=string_replace_all(argument0,"\D||%%&^%$&^}{:)(**_**%(^#","%34");
  argument0=string_replace_all(argument0,"\E||%%&^%$&^}{:)(**_**%(^#","%35");
  argument0=string_replace_all(argument0,"\F||%%&^%$&^}{:)(**_**%(^#","%36");
  argument0=string_replace_all(argument0,"\G||%%&^%$&^}{:)(**_**%(^#","%37");
  argument0=string_replace_all(argument0,"\H||%%&^%$&^}{:)(**_**%(^#","%38");
  argument0=string_replace_all(argument0,"\I||%%&^%$&^}{:)(**_**%(^#","%39");
  argument0=string_replace_all(argument0,"\J||%%&^%$&^}{:)(**_**%(^#","%30");

  argument0=string_replace_all(argument0,"A","%41");
  argument0=string_replace_all(argument0,"B","%42");
  argument0=string_replace_all(argument0,"C","%43");
  argument0=string_replace_all(argument0,"D","%44");
  argument0=string_replace_all(argument0,"E","%45");
  argument0=string_replace_all(argument0,"F","%46");
  argument0=string_replace_all(argument0,"G","%47");
  argument0=string_replace_all(argument0,"H","%48");
  argument0=string_replace_all(argument0,"I","%49");
  argument0=string_replace_all(argument0,"J","%4A");
  argument0=string_replace_all(argument0,"K","%4B");
  argument0=string_replace_all(argument0,"L","%4C");
  argument0=string_replace_all(argument0,"M","%4D");
  argument0=string_replace_all(argument0,"N","%4E");
  argument0=string_replace_all(argument0,"O","%4F");
  argument0=string_replace_all(argument0,"P","%50");
  argument0=string_replace_all(argument0,"Q","%51");
  argument0=string_replace_all(argument0,"R","%52");
  argument0=string_replace_all(argument0,"S","%53");
  argument0=string_replace_all(argument0,"T","%54");
  argument0=string_replace_all(argument0,"U","%55");
  argument0=string_replace_all(argument0,"V","%56");
  argument0=string_replace_all(argument0,"W","%57");
  argument0=string_replace_all(argument0,"X","%58");
  argument0=string_replace_all(argument0,"Y","%59");
  argument0=string_replace_all(argument0,"Z","%5A");

  argument0=string_replace_all(argument0,"a","%61");
  argument0=string_replace_all(argument0,"b","%62");
  argument0=string_replace_all(argument0,"c","%63");
  argument0=string_replace_all(argument0,"d","%64");
  argument0=string_replace_all(argument0,"e","%65");
  argument0=string_replace_all(argument0,"f","%66");
  argument0=string_replace_all(argument0,"g","%67");
  argument0=string_replace_all(argument0,"h","%68");
  argument0=string_replace_all(argument0,"i","%69");
  argument0=string_replace_all(argument0,"j","%6A");
  argument0=string_replace_all(argument0,"k","%6B");
  argument0=string_replace_all(argument0,"l","%6C");
  argument0=string_replace_all(argument0,"m","%6D");
  argument0=string_replace_all(argument0,"n","%6E");
  argument0=string_replace_all(argument0,"o","%6F");
  argument0=string_replace_all(argument0,"p","%70");
  argument0=string_replace_all(argument0,"q","%71");
  argument0=string_replace_all(argument0,"r","%72");
  argument0=string_replace_all(argument0,"s","%73");
  argument0=string_replace_all(argument0,"t","%74");
  argument0=string_replace_all(argument0,"u","%75");
  argument0=string_replace_all(argument0,"v","%76");
  argument0=string_replace_all(argument0,"w","%77");
  argument0=string_replace_all(argument0,"x","%78");
  argument0=string_replace_all(argument0,"y","%79");
  argument0=string_replace_all(argument0,"z","%7A");

  argument0=string_replace_all(argument0,"-","%2D");
  argument0=string_replace_all(argument0,"_","%5F");
  argument0=string_replace_all(argument0,".","%2E");
  argument0=string_replace_all(argument0,"~","%7E");
}
argument0=string_replace_all(argument0,"|%%&^%$&^}{:)(**_**%(^#","%25");

argument0=string_replace_all(argument0," ","%20");
argument0=string_replace_all(argument0,"!","%21");
argument0=string_replace_all(argument0,"'","%27");
argument0=string_replace_all(argument0,"(","%28");
argument0=string_replace_all(argument0,")","%29");
argument0=string_replace_all(argument0,";","%3B");
argument0=string_replace_all(argument0,":","%3A");
argument0=string_replace_all(argument0,"@","%40");
argument0=string_replace_all(argument0,"&","%26");
argument0=string_replace_all(argument0,"$","%24");
argument0=string_replace_all(argument0,"/","%2F");
argument0=string_replace_all(argument0,"?","%3F");
argument0=string_replace_all(argument0,"#","%23");
argument0=string_replace_all(argument0,"[","%5B");
argument0=string_replace_all(argument0,"]","%5D");
argument0=string_replace_all(argument0,"=","%3D");
argument0=string_replace_all(argument0,"+","%2B");
argument0=string_replace_all(argument0,"*","%2A");
argument0=string_replace_all(argument0,"{","%7B");
argument0=string_replace_all(argument0,"}","%7D");
argument0=string_replace_all(argument0,"|","%7C");
argument0=string_replace_all(argument0,"\","%5C");
argument0=string_replace_all(argument0,'"',"%22");
argument0=string_replace_all(argument0,",","%2C");
argument0=string_replace_all(argument0,"<","%3C");
argument0=string_replace_all(argument0,">","%3E");
argument0=string_replace_all(argument0,"~","%7E");
argument0=string_replace_all(argument0,"`","%60");

return argument0;

  • 0

#6 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 19 April 2009 - 08:27 PM

Ahem, when you are doing it with large amounts of data, a dll is faster.
  • 0

#7 IsmAvatar

IsmAvatar

    Good Samaritan

  • GMC Member
  • 2411 posts
  • Version:GM8

Posted 19 April 2009 - 09:19 PM

Hockeyflyers: Next time use codebox.
argument0=string_replace_all(argument0," ","%20");argument0=string_replace_all(argument0,"!","%21");argument0=string_replace_all(argument0,"'","%27");argument0=string_replace_all(argument0,"(","%28");argument0=string_replace_all(argument0,")","%29");argument0=string_replace_all(argument0,";","%3B");argument0=string_replace_all(argument0,":","%3A");argument0=string_replace_all(argument0,"@","%40");argument0=string_replace_all(argument0,"&","%26");argument0=string_replace_all(argument0,"$","%24");argument0=string_replace_all(argument0,"/","%2F");argument0=string_replace_all(argument0,"?","%3F");...

Edited by IsmAvatar, 19 April 2009 - 09:19 PM.

  • 0

#8 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 20 April 2009 - 01:06 AM

Stay on topic, folks!
  • 0

#9 Recreate

Recreate

    Furry

  • GMC Member
  • 2986 posts
  • Version:GM:Studio

Posted 20 April 2009 - 03:53 AM

I saw a request for a Base64 DLL, and I thought, "I'll make one!" (and I needed one for my current project).

So I made one.

This zip contains the example and the dll. Post your comments and suggestions here.

TEH LINK

Please give credit!!

PS: This is my FIRST DLL!

What does this do
  • 0

#10 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 20 April 2009 - 04:23 AM

Encodes into Base64. Read the wikipedia thing about it.
  • 0

#11 Recreate

Recreate

    Furry

  • GMC Member
  • 2986 posts
  • Version:GM:Studio

Posted 20 April 2009 - 04:29 AM

Oh...looks like something usefull for paranoid people(not really in fact i already found a use)
Does this encode and decode files? Or strings?
  • 0

#12 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 20 April 2009 - 12:32 PM

Strings, but eventually files.
  • 0

#13 Recreate

Recreate

    Furry

  • GMC Member
  • 2986 posts
  • Version:GM:Studio

Posted 21 April 2009 - 03:44 AM

Strings, but eventually files.

Oh...Still usefull
  • 0

#14 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 21 April 2009 - 03:58 AM

Eventually It will be files.
  • 0

#15 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 22 April 2009 - 07:50 PM

Oh...looks like something usefull for paranoid people

Encoding is not encryption.
Encoding is something used to make data more easy to transfer, for example, in XML tags, or to a MySQL database.
It is occasionally used for light obfuscation of text to avoid google from finding pages it shouldn't.
It is, by design, easy to reverse.

Encryption, on the other hand, is NOT meant to be reversed. It is made to keep data from being read or (in the case of signing a message) altered.

Digest algorithms are a completely different kettle of fish - they purposely lose enough data as to make the result almost impossible to get the original text from - it's sometimes used to check pairs of sensitive data against each other.
  • 0

#16 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 22 April 2009 - 08:16 PM

Like passwords...

Encoding is MEANT to be decoded. Like Binary Data over a Text only protocol!
  • 0

#17 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 19 June 2009 - 03:55 PM

Added File Support.
Please redownload.
  • 0

#18 lucb1e

lucb1e

    GMC Member

  • GMC Member
  • 13 posts
  • Version:GM8

Posted 12 December 2010 - 08:19 PM

Sorry for the bump, but does someone still have this? Gmtoolbox also links here.
  • 0

#19 LSnK

LSnK

    NaN

  • GMC Member
  • 1188 posts

Posted 12 December 2010 - 09:39 PM

Nope. If it's any help, here's one I wrote before.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users