DevonRevenge's decoding challenge #1: I scrambled a sentence can you decode it(with algorithm provided)

Pages: 12
So i scrambled a sentence with a function that was 16 lines of code

usigfqedtwjsvusygih



EDIT: I have no idea how easy its gonna be;if its too hard i could submit the coder but that might then be too easy

EDIT2: Heres another mulooqlrizlok

EDIT3:heres the algorithm that scrambled it: int q = (a+b)*cipher%27;
a = letter pos in sentence, b position in 27 char alphabet, cipher is the cipher
so make a program that decodes it :D

EDIT4:it is reversible, a java function decoded it
Last edited on
How do we know if the function is reversible?
it is cos i built another function to reverse it, but it might be quite hard;but i will submit an easy level too
Last edited on
Give us some time and we will solve this.

EDIT:
When I read scrambled I thought shuffled but if it's encrypted in some more advanced way it can be very hard to solve because there could be thousands of possible solutions.
Last edited on
Yes knowing whether or not it is just scrambled (ie same letters as original, just different order) or encrypted would be nice to know.
I decode it as "banana". Besides it not being the word you wanted, there is no way to show that I am wrong. There does indeed exist an encoding that takes "banana" to "usigfqedtwjsvusygih". The challenge is not had, it is plain impossible.
@ devonrevenge: I want to know if your code does selective substitution.
I figured it out with hamsterman's help

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <string.h>

int main()
{
string EncryptedMessage;
std::cout << "Enter Encrypted Message : ";
std::cin >> EncryptedMessage;
std::cout << "Decrypted Message : Banana";
return 0;
}
heres the algorithm that scrambled it: int q = (a+b)*cipher%27;
a = letter pos in sentence, b position in 27 char alphabet, cipher is the cipher

It was too hard to just suss out but i got the best idea for challenge 2 you will love it

@catfish, could you give me an example of that?
Last edited on
int q = (a+b)*cipher%27;
a = letter pos in sentence, b position in 27 char alphabet, cipher is the cipher
This may not be reversible. If cipher is a multiple of 27, (a+b)*cipher%27 == 0 for all values of a and b.
no it is my mathmetician freind helped me...well actually he said the same thing but then couldnt understand how i came up with code in the first place...% isnt really what mathmeticians call modulos its the coding version (it has a different name i think modulous just cought on) basically i thing the remainder is returned as an int so it is reversable (cos alphabet [30]%27 = 3 (so 'c') )

my mathmetician freind built the reverse function with the algorithm ^_^
Last edited on
@ devonrevenge: by "selective substitution" I meant a switch() that only replaced certain letters and left others as they were.

cipher is the cipher

Which is what? Do you mean "key"? A number given by the user?
well actually he said the same thing but then couldnt understand how i came up with code in the first place
Just because a function is invertible in a subset of its domain doesn't mean it's completely invertible. See for example x*x and sqrt(x). You can't prove that the function you wrote is the inverse of this for all possible inputs.

% isnt really what mathmeticians call modulos its the coding version (it has a different name i think modulous just cought on)
The difference is only relevant for negative integers. For naturals, % is equivalent to the remainder function.

The remainder of the division a/b is an integer r such that a = b*q+r, where q is some integer and 0<=r<b. If cipher is a multiple of 27, then it's expressible as 27*k, where k is some integer. Then
(a+b)*cipher%27 == (a+b)*(27*k)%27 == (a*27*k+b*27*k)%27 ==
by properties of remainder:
== ((a*27*k)%27+(b*27*k)%27)%27 ==
and again:
== (((a%27)*(27%27)*(k%27))%27+((b%27)*(27%27)*(k%27))%27)%27 ==
by definition of remainder, for all integer values of c different than 0, c%c == 0. In particular, 27%27 == 0:
== (((a%27)*0*(k%27))%27+((b%27)*0*(k%27))%27)%27 ==
== (0%27+0%27)%27 == 0%27 == 0

Trust me, I've been doing proofs like this all year. The function is not fully invertible.
cipher is just a number in this case, 4.
the reversing function has worked perfectly for all sentences so far
Last edited on
cipher is just a number in this case, 4.
Well, try 27.
I'd love to see your alphabet, devon. I figured out what the messages are, but some of the letters are wrong.
even if cipher = 4, a+b could be divisible by 27. 'k' at position 1 and 'O' at position 2 (sums 108 and 81) both "encrypt" to 0. oops, assumed ascii...
Instead just 'b' at position 26 and 'a' at position 27.
Last edited on
the alphabet is a=0 and so on but with 27 = ' '.

the cipher was between 2 and 9, shouldn't modulus always just keep it all together ie: 3 = 'c', 30 = 'c' 57 = 'c' etc etc rah rah rah?

my idea for the second one is sooo much cooler but i will test it a lot more
Last edited on
Could you please just copy paste the alphabet as it is in the code?
Because either I messed up the "decoder", or you messed up the alphabet.
oh wait, for 4 it totally is reversible. if it was 6 though, you'd have 'i' = 'r' (9 = 18) at any position.
Pages: 12