-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rail fence decode does not appear to work as expected #1163
Comments
What's odd is that the input length is 11; if the decode is a key length of 2 then the length is 11, but if the key length is 3 then the decode length is 12 and an extra space appears. If I use "JollyBroken " with a space afterwards, the encode/decode works as expected. |
It’s the same issue as #1108 but I don’t know that #1069 will solve the problem. When encoding “JollyBroken” it gets displayed as “JykolBoelrn” with no spaces, but although the output of encode says “Length: 11” for the text, it also says “Length: 12” for the output of the cipher, which I suspect is where the space is coming from. Simply deleting spaces isn’t going to fix the problem — if you type “JykolBoelrn” (no spaces) into a Rail Fence decode with key 3, it produces the incorrect output whether or to the space is there in the output. The issue seems to be that the decode is ‘rounding up’ the length of the string (11) to the nearest multiple of the key (12) which then affects the algorithm. Using a Rail Fence Encode with key 3 and “JollyBroken” and piping the output to hexdump shows that the output generated by the Encode isn’t adding any additional spaces to the output, so stripping the spaces in the encode isn’t going to fix a problem. Similarly, the output claimed by the Encode is 11 (same as input) so there’s no spaces being introduced there. The problem appears to be that the Rail Fence Decode rounds up the length to the nearest multiple of the key, and that introduces the space into the mix,. |
Yup, looks like #1071 will fix this issue as well. |
BTW this came up because one of the questions in https://www.ncsc.gov.uk/cyberfirst/girls-competition uses a rail fence encoding and my daughter found this issue in CyberChef. Reproduced here with a different example so as not to give the game away :) |
This should be closed by #1071 |
This works now on the website as of the build an hour ago |
Describe the bug
Text created with the 'Rail Fence Encode' does not appear to be decodable with 'Rail Fence Decode' with the same key and offset.
To Reproduce
Click on https://gchq.github.io/CyberChef/#recipe=Rail_Fence_Cipher_Encode(3,0)Rail_Fence_Cipher_Decode(3,0)&input=Sm9sbHlCcm9rZW4 to load it in the simulator, or alternatively:
Expected behaviour
When using the same cipher to encode and decode data, I would expect to see the plaintext in the result unchanged.
Screenshots
Additional context
Taken on the version on the website at time of raising bug,
Version 9.21.4
Compile time: 22/01/2021 19:00:54 UTC
The text was updated successfully, but these errors were encountered: