how to make the decryption program?

Hello there ^^.

I made an encryption program that successfully encrypts data but my problem is this: How to create it decryption program? Looks like because I used a lot of bitwise operators in this program some 0s or 1s are lost so it looks like a hashing program instead of a encryption program.. I thought that I would save those lost bits in a string but how?
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
51

	int salphanum = sizeof(alphanum);
	for (int n = 0; n < jc9b1l; n++) {
		C1[n] = alphanum[((jc9b1[n] + jc9b2[n+1])) % salphanum];
	}
	for (int n = 0; n < (jc9b1l); n++) {
		C2[n] = alphanum[((jc9b2[n] + jc9b1[n+1])) % salphanum];
	}
	std::string E1 = C2;
	std::string E2 = C1;
	for (int n = 0; n < jc9b1l; n++) {
		E1[n] = alphanum[(((C1[n] & C2[n+1]) ^ 'R'  )) % salphanum];
	}
	for (int n = 0; n < jc9b1l; n++) {
		E2[n] = alphanum[(((C2[n] ^ C1[n+1]) ^ 'K'  )) % salphanum];
	}
	std::string O1 = E2;
	std::string O2 = E1;
	for (int n = 0; n < jc9b1l; n++) {
		O2[n] = alphanum[(((E2[n] ^ E1[n+1]) ^ 'H'  )) % salphanum];
	}
	for (int n = 0; n < jc9b1l; n++) {
		O1[n] = alphanum[(((E1[n] | E2[n+1]) & ~i[n])) % salphanum];
	}
	std::string Y1 = O1;
	std::string Y2 = O2;
	for (int n = 0; n < jc9b1l; n++) {
		O2[n] = alphanum[(((E2[n] ^ E1[n+1]) ^ 'R'  )) % salphanum];
	}
	for (int n = 0; n < jc9b1l; n++) {
		O1[n] = alphanum[(((E1[n] | E2[n+1]) & ~i[n])) % salphanum];
	}
	std::string R1 =  O2;
	std::string R2 =  O1;
	for (int n = 0; n < jc9b1l; n++) {
		R1[n] &= O2[n];
		R2[n] &= O1[n];	
	}
        std::string T1 = R1;
	std::string T2 = R2;
	std::string D2 = T2;
	for (int n = 0; n < jc9b1l; n++) {
		T2[n] |= alphanum[(((R1[n] ^ m ))) % salphanum];
		D2[n]  = alphanum[T2[n] % salphanum];
	}
	for (int n = 0; n < jc9b1l; n++) {
		T1[n] = alphanum[(((R1[n] | R2[n+1]) & ~i[n])) % salphanum];
	}
	std::string E = T1 + D2;
	std::cout << E << "\n";
}

PS: Sorry for my English
Last edited on
How to create it decryption program?
If you who created the encryption function don't know that, who will?

I thought that I would save those lost bits in a string
That doesn't sound practical. Different bits may be lost or added at different points in the algorithm, or even depending on the values of other bits. If you understand your algorithm sufficiently to save that information, you probably understand it enough to be able to remove the bit lossage.
Thanks a lot for your help . I actually dont fully understand my algorithm and that pisses me off (dont ask why and how i just added some random bitwise opperators)..
But again i read that & and | can cause data loss.

I wanna to know How to save those lost bits in a string
Also i dont want to remove the bit lossage. I know how but i dont want to.
I don't see the point of asking a question if you're just going to ignore the advice given.

Assuming that you can figure out how to save lost bits, how are you going to store them? In plaintext or encrypted?
Well i wanna save them in plaintext.
Also i dont want to prevent this data loss cause it makes hard to decrypt without those lost bits.
This data loss is going to be something like a key.
Also i dont want to prevent this data loss cause it makes hard to decrypt without those lost bits.
Huh? The point of cryptography is to encapsulate an insecure channel to be able to treat it as a secure channel through which to transmit data. If you have a channel that's secure enough to transmit the lost bits then you have a channel that's secure enough to transmit the original plaintext.

This data loss is going to be something like a key.
If I use your algorithm to encrypt 1 gigabit of information, in all likelihood I'm going to get around 500 megabits of key. That's not all that easier to keep secure than the original message. I'm much better off generating a one-time pad and XORing it with the plaintext. That key is only twice as long, but the ciphertext is completely unbreakable, and the algorithm is several orders of magnitude simpler to implement.
You are totally right. I am gonna fix this thanks a lot .
Topic archived. No new replies allowed.