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

Pages: 12
Dec 18, 2012 at 3:19pm
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 Dec 19, 2012 at 3:42pm
Dec 18, 2012 at 3:57pm
How do we know if the function is reversible?
Dec 18, 2012 at 4:04pm
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 Dec 18, 2012 at 4:05pm
Dec 18, 2012 at 4:14pm
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 Dec 18, 2012 at 4:23pm
Dec 18, 2012 at 4:29pm
Yes knowing whether or not it is just scrambled (ie same letters as original, just different order) or encrypted would be nice to know.
Dec 18, 2012 at 5:15pm
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.
Dec 18, 2012 at 5:15pm
@ devonrevenge: I want to know if your code does selective substitution.
Dec 19, 2012 at 12:30am
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;
}
Dec 19, 2012 at 2:44pm
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 Dec 19, 2012 at 2:45pm
Dec 19, 2012 at 3:14pm
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.
Dec 19, 2012 at 3:19pm
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 Dec 19, 2012 at 3:51pm
Dec 19, 2012 at 4:10pm
@ 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?
Dec 19, 2012 at 5:18pm
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.
Dec 19, 2012 at 5:54pm
cipher is just a number in this case, 4.
the reversing function has worked perfectly for all sentences so far
Last edited on Dec 19, 2012 at 5:55pm
Dec 19, 2012 at 5:57pm
cipher is just a number in this case, 4.
Well, try 27.
Dec 19, 2012 at 6:27pm
I'd love to see your alphabet, devon. I figured out what the messages are, but some of the letters are wrong.
Dec 19, 2012 at 6:39pm
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 Dec 19, 2012 at 6:42pm
Dec 19, 2012 at 6:58pm
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 Dec 19, 2012 at 6:58pm
Dec 19, 2012 at 7:00pm
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.
Dec 19, 2012 at 7:03pm
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