arrays in algorithm of cryptography

Hi everyone!

I'm going to explain what I already have and what I want to do, I'm not going to show the full code because more than 800 lines.

My code is about encoding and decoding, its simple. Example: if I want to encode the word "cplus"

lets say:
c = 000010111
p = 011110001
l = 111001010
u = 010111101
s = 011011001

(its just an example), but the idea is that I use a loop (while) then I print the letter in a note pad. (letter by letter).

if we say that (text = cplus) and (i = 0) (each letter have 9 numbers)

This is going to be 'layer 1'
1
2
3
4
5
6
7
8
9
switch(text[i])
{
	case 'c': {fputs("000010111", Notepad); break;}
	case 'p': {fputs("011110001", Notepad); break;}
	case 'l': {fputs("111001010", Notepad); break;}
	case 'u': {fputs("010111101", Notepad); break;}
	case 's': {fputs("011011001", Notepad); break;}
}
i++;


The program works great, the output is:
(Inside a notepad)
000010111011110001111001010010111101011011001

When I want to decode it, its the same just a little change:

1
2
3
4
5
6
switch(text[i])
{
	case '000010111': {fputs("c", Notepad); break;}
	//and so on
}
i++;


and it works great.

Now what I want to do? I want to make it more complex.

This is what I want to do, lets say:
000010111011110001111001010010111101011011001

now we have 18 numbers underline, I want to take the 18 numbers (letter c and p) and "put them together"

we got this 18 numbers (12 of those numbers are underline now):

000010111011110001

I want to take for example 12 numbers and change the value with those 12 numbers to other value. Lets say

This is going to be 'layer 2'
1
2
3
4
switch(text[i])
{
	case '000010111011': {fputs("23", Notepad); break;}
}


One easy way to do this is...
I print the numbers of layer 1 in a note pad (as I already did). Then I start again, now with layer 2 and I take now 12 numbers, then I change the value (of layer 1) for the new value (of layer 2) and print the value of those 12 in another note pad and then with the next 12 numbers and so on. But I want without printing the "first layer" in a note pad, then print another notepad with the "second layer", so what I want to do is pass the first layer using functions (or something) for example...

cplus encoded is
000010111011110001111001010010111101011011001

so all that code pass it by function or some way that I can in layer 2 take 12 of those numbers.

Here the difficult thing is that if I'm using a loop I can instead of 'fputs' I can send each letter encoded to an array (each letter encoded have 9 digits for example) but the problem is going to be that when I want to take those 12 numbers its not going to be possible (as far as I know) because for example:

array[0] have 9 numbers and array[1] have other 9 and I want 12, so what can I do/use here for solve this problem?

Is there a way to..., for example, I encode letter C and send it to
int b
then I encode letter p and send it to
int b
but with the the letter c too. All together?

How can I do this?

Btw, thanks cause reading.
Last edited on
Topic archived. No new replies allowed.