Let's say that we are given a string: "abcdefg..." and the cipher says it is supposed to + 100 in value so a = 97 + 100 which is 197 which is Å. But let us say that there is such a letterthat gets encoded into \0, what should we do to avoid or deal with this problem? Since it may cut the decoding short as it is returning a the string shorter as it thinks that it has ended.
#Encoding and decoding a message.
86 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.
\0 is 0
so if cypher is only adding, it's safe
problem may occur with 'del' character though
it will do del if original char value is 27, 27 is escape
so it's unlikely
also, they have the same effect I think
**** Original input message:
As much as you can,
Even if you cannot shape your life as you want it,
at least try this:
as much as you can; do not debase it
in excessive contact with the world,
in the excessive movements and talk.
Do not debase it by taking it,
dragging it often and exposing it
to the daily folly
of relationships and associations,
until it becomes burdensome as an alien life.
Constantine P. Cavafy (1913)
**** Encrypted text lines:
~yPΩ↕||4ô½~ZTSy£Åà?'▓¥ºk½[q¥¼ àï3ÿù╤STOq«ôzüä╢╔á}╚&ì╟═tgtΓ:↨ZZ♣\M♠ÄÄü│9hT⌂z&ô├┤à┴/ßì↔
YMNa╚'è|½-╙ú~|S╕≥6±ƒûu÷┼]%▀N^{
**** Decoded text lines (should be identical to original input!):
As much as you can,
Even if you cannot shape your life as you want it,
at least try this:
as much as you can; do
;compile
#include <stdio.h>
int main(void)
{
char test[10] = "testline\0";
printf("%s\n", test);
test[4] = 127;
printf("%s\n", test);
test[4] -= 100;
printf("%s\n", test);
return 0;
}
this is the output i am getting, as you can see the \0 seem to be cutting it off
your cypher seems broken
text has 'n' and spaces before but they don't break the program
the cypher is one where it takes a pgm as a cypher
?
it is as intended, like we take an image and use such image to encode or decode a text
space is also taken into consideration
show code pls
what if you try %127 instead of 255?
in both encryption and decryption ?
yep
I think I see the problem
you're treating the array as one longitudinal array
so it'll reach '0' on the 50th character
you're supposed to decouple your 0-2500 variable into two 0 50 variables
wut
ah wait
i dont think that matters
let me send u a ss of the image to decode
we use this to decode it, so i just made it into an array to make it simpler to decode
instead of [][] just []
yeah i see that now

what is gdb
a debugger
what happens when you remove that if (result < 0) {
result += 255;
}
returns nonesense
i dont understand why previous n and spaces get cyphered/decyphered correctly and this one would break the program
that's why I think the problem is elsewhere
space as a ascii value
i know
32
but you cyphered spaces before with the same algo
and it goes on
so why break there ?
and there is also some other random value that added with some other value, equates to \0? no?
yesh yesh
okok
so let's say it's inevitable to sometimes have a char value of 0, or del
you don't want to see that happen
so don't use ascii
bruh
its ok, i will just wait for someone else to enlighten me
good luck on that, I'll think about the problem for a bit
well
are you allowed to modify the values of passArr
no
you sure ? technically creating a passArr is some kind of improvisation
I dont see why you could not push it a bit further
the image you enter is like a token or key
you cannot really go around changing the key itslef
I understand that but I meant inside the functions
like, modify the interpretation of the image
yesh
anyway you could secure an algoritm that ensure a certain value range
not sure about the 128-255 range but if they're all printable make sure it's in there ?
you could also go between 33 and 126
so you modulo 93 and do + 33
and go the opposite way in decypher
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.