#Repeating pattern in encryption
80 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
{
int u = SL/2 + i;
char L = S[i];
char R = S[u];
for (short int k = 0; k < 4; k++)
{
short int T = A[k][k + 1] + i;
L ^= T + K;
R ^= T + C(K);
}
L ^= C(K);
R ^= A[0][1] * K;
if (L == 0 || L == 10 || L == 32 || L == 8 || L == 7 || L == 9 || L == 13) L <<= 1;
if (R == 0 || R == 10 || R == 32 || R == 8 || R == 7 || R == 9 || R == 13) R <<= 1;
S[i] = L;
S[u] = R;
}```
this is for both encryption and decryption
{
int B = A[0][X >> 32 & 8] + A[3][X >> 16 & 4];
return (B ^ A[1][X >> 8 & 2]) >> 12;
}```
the real answer is to never roll your own encryption
:(
I don't know what S and A are
S is the string
{07321,13908,86778,44329,53288,81847,82277,56246},
{31701,87817,72960,23541,30606,72136,04600,79250},
{87402,56425,34708,79089,13729,17228,28611,51591},
{69054,65937,46161,93238,40363,89313,13643,27137}
};```
i wouldn't discourage it if it's just for fun, but if you're actually trying to encrypt something real, you should use an existing encryption algorithm because most likely yours will be cracked easily
the encryption algorithm works for decypriotn as well
im not
A[k][k + 1]```
i mean yeah mine is just for fun
is a diagonal
it's not A[k][k] which is a major diagonal, but it is one off
so
If you get a repeating pattern in the output, I suspect it is because of a repeating pattern in the input
yeah, but that shouldn't happen
why not?
by the way, if you actually want to prevent it from being read, you will need to have a key
Input:
Hello world! Hello world! Hello world! Hello world!Hello world! Hello world! Hello world! Hello world!Hello world! Hello world! Hello world! Hello world!Hello world! Hello world! Hello world! Hello world!Hello world! Hello world! Hello world! Hello world!Hello world! Hello world! Hello world! Hello world!Hello world! Hello world! Hello world! Hello world!
Ouput:
ı~6ä[<Æ═åɧɲâÞ─^mZH⌂p6GÛ½òéµÞ╗ê‗)6:female_sign:§<mGXP¥ÐBë÷:diamonds:ı¼═/(~:arrow_up_down:Û¶ƒ\µú:ƒı■Â:diamonds:[─¥ü║¼Ðä¨þ:diamonds:↑☻a♫\ktZïÂù▒ÂÔýÎ∟#L☻{nOY▬zñƒ:diamonds:ã¡→ÏIá↓{╝t:arrow_up_down:┼
vÞ{ÞÔ'Íú)RB/X¥:relaxed:║¼Ð:diamonds:yþ:diamonds:↑éaµqÔ¶Y─ß☼¼(Û)V£#L鹯O┘û·ñƒäF-→XI@↓{╝¶Æ┼÷Þ¹ÞÔ'V#)RBp/░ôê║»×Ëß·→►G`fqbtY─ßż¿Û:registered:Í∟#L☻{nOY▬zñƒ:diamonds:ã¡→Ï
Iá↓{╝t:arrow_up_down:┼```
otherwise someone reading the code will reverse engineer your algorithm
K is a 32 bit int, so we're shooting for weak encryption I guess
what?
I guess you've only tested it on ascii
yeah i did
bit shift are inside a function which always run the same code with the same input
because if you reach the if statements with bad values of L, like, L = 10 and L = 20, the results are indistinguishable in the output
and by shifting it by 12 bits i get a 2 digits integer
oh thattt
i haven't tested it yet
but yeah, that probably does ruin things
guess im not gonna bit shift there tho
maybe add the key length to the character
I don't understand what the purpose of this is
are you trying to protect real data from real adversaries? if so, your only bet is to go download a good C encryption library
im not
If you want this, you should make the previous bytes affect the encryption of the current plaintext
Instead of encrypting everything individually
oh you're right supsm
wait what do you mean by previous bytes?
S[(i - 1) * (i > 0)]
ie l, if you encrypt
aaaaaa z
or
bbbbbb z
should z correspond to the same output in the ciphertext?
if you take into account the previous part of the message, the answer would be no
https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
see this, it has some stuff you can take inspiration from
thanks! I will look into it
@smoky pulsar Has your question been resolved? If so, run !solved :)
Thank you and let us know if you have any more questions!
do you realize you're yelling at a bot?