views:

416

answers:

6

The question is for any modern unmanaged language.C-like languages,delphi,anything.

I'd like to create my own cryptography algorithm that ,unlike others,decreases the length of the encrypted string.

My first thought was to create my own numberic system similiar to hexadicimal,but with more characters.For example [0..9] + [A..Z].That would make a number upto 40 into one digit value.I could also add other digits such as '!,./?)(#!' and so on.

My question is how to implement such numberic system from A to Z inculding 0 to 9.Do I have to declare every single value as constant up to 0xZZZZZZZZ? that would make my life terrible

Please give me your suggestions,examples. :)

+4  A: 

Typically the way encryption algorithms reduce the size of the encrypted text is to run the text through a general purpose compression algorithm first, then encrypt the compressed result. You will almost always get a better result this way than trying to combine the two algorithms into one.

Greg Hewgill
+5  A: 

You would need to change way how computers and storage works.

There is no free memory and there is no way of getting space for free. Changing number system would give you more space when you write it on paper, but in computer memory, you still need same amount of bits.

Also notice that, if you want to encrypt something, that operation also prevents any meaningful compression since encrypted content must be as near to random as possible.

Usually some form compression is done BEFORE encryption (GZip or something similar) but that does not work by changing number systems.

P.S. Use some proven encryption algorithm.

Josip Medved
+1  A: 

I would recommend simply compressing the input (using gzip, zlib, or whatever) before encrypting it. This is easier and more secure than creating your own algorithm. (GnuPG does this, for example.)

grawity
+2  A: 

Let's think about this.

Each Base 40 character takes up 8 bits. It encodes a number from 0 to 39, which is just a hair more than of 5 bits of actual information.

A single byte can represent 256 different values. A base 40 encoding only represents 40 different values in that same byte.

This seems to be a net loss of 2-3 bits per byte encoded.

Having said that, a base 40 value IS a string and nothing more. No fancy database declaration is required -- it's just a string.

You write two functions -- toBase40( someBytes ) and toBytes( someBase40string ) to convert your base40 strings to ordinary strings.

If you want a well-done existing solution, research base64.

S.Lott
+1  A: 

Base64 strings are common in many computer languages and it's pretty standard. It uses the following characters:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

See http://en.wikipedia.org/wiki/Base64 for more information

Jader Dias
+2  A: 

The people who have developed encryption algorithms have spent probably millions of man hours, years in grad school and post-docs to get their expertise. What makes you think you can come up with something better?

You will probably come up with an unsecure algorithm.

Use an existing algorithm and use compression.

Larry Watanabe
I'll second that. This Coding Horror's post explains better than I ever could: http://www.codinghorror.com/blog/archives/001275.html
Jader Dias
I did post previously the wrong link, so if you checked it already please check it again
Jader Dias