|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
can you reverse this cipher?
This cipher is really simple, but I tried for 5 minutes to find a strategy to reverse it and can't (yet). I'm sure this has been thought of before, but here goes:
Code:
plaintext: devshed ciphertext: iaoamih Algorithm: convert the letters to their ordinal values (a = 1, b = 2, etc.) devshed = 4 5 22 19 8 5 4 each position then gets the sum of its value and the next: = 9 27 41 27 13 9 8 (the last position gets the sum of its value and the very first position's initial value) mod 26 (not exactly, but essentially): = 9 1 15 1 13 9 8 convert back to alpha based on ordinal values = iaoamih given ciphertext: idhfnsln what is the plaintext? this is not case sensitive.. assume all lowercase
__________________
|
|
#2
|
|||
|
|||
|
here is some PHP code to create the ciphertext from plaintext:
PHP Code:
just put the above code into a file (cipher.html ?) on a PHP webserver, then request this (fake) URL: http://mywebserver.com/cipher.html?text=mytext I have it running right here. Last edited by JunkCookie : October 5th, 2004 at 04:19 PM. |
|
#3
|
|||
|
|||
|
have been playing around with this, and, at least for the input 'oaxaca', connecting the output to the input and interating a few times eventually puts you into a loop, where the ouput is eventually an output you have seen before.
I'm pretty new to crypto, but if anyone wants to enlighten me, I'm all ears //EDIT: these two inputs give the same output: pyyddp & cllqqc each letter of the two strings have the same offset, except one string is relative to A and the other to N, take your pick Last edited by JunkCookie : October 5th, 2004 at 07:23 PM. |
|
#4
|
|||
|
|||
|
if you take each position as variables with letters a b c d e f g etc
4 5 22 19 8 5 4 maps into a+b b+c c+d d+e e+f f+g g+a (all mod 26) 9 1 15 1 13 9 8 now just undo by adding and subtracting alternately 9-1+15-1+13-9+8 =34 mod 26= = 2a 8/2 = 'd' (a+b)-(b+c)+(c+d)-(d+e)+(e+f)-(f+g)+(g+a) -> a +b-b -c+c +d-d -e+e +f-f -g+g +a = 2a 1-15+1-13+9-8+9 = 10 mod 26 = 2b 10/2 = 'e' 15-1+13-9+8-9+1 = -8 mod 26 = 2c -8/2 = -4 mod 26 = 22 = 'v' etc. you have 7 linear equations you can think of it that way too |
|
#5
|
|||
|
|||
|
Quote:
idhfnsln = 9 4 8 6 14 19 12 14 Code:
$a := 9 - 4 + 8 - 6 + 14 - 19 + 12 - 14 == 0; // since 0 represents 'z' and not 'a' by my definition, we don't do mod 26 exactly.. // rather do: $letternum = (($value - 1) % 26) + 1 $a := ($a - 1) % 26 + 1 == 26; $a := $a/2 == 13; char($a) == 'm'; hmm.. the first letter of the plaintext is not m. I must be missing something.. |
|
#6
|
|||
|
|||
|
It's not reversible, taking the modulus means that different plaintexts may produce the same cyphertext.
Consider the cyphertext "zz" - it is the result of encoding the plaintext "mm" and also the result of encoding "zz". Not hard to reverse otherwise, I'd guess, haven't looked at it, but if you know the first letter then the rest will follow. Hence only twenty six alternatives to consider. As for adding and subtracting alternately, it will give twice the first character (as above) only for odd-numerbered length strings, even numbered length strings will always give zero (which is not in the range 1 to 26 and should have been an obvious indication of a flaw in your method...) Last edited by epl : October 17th, 2004 at 11:05 AM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Software Design > can you reverse this cipher? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|