Message Boards Message Boards


Encode/Decode bug?

Posted 8 years ago
3 Replies
4 Total Likes

I was playing around with the Encode/Get functions - specifying a key, and found that an encoded package could be decoded with numerous other keys. The below code works on all encoded files that I have tried:

chars = CharacterRange["a", "z"];
keys = DeleteDuplicates[Flatten[Table [a <> b <> c, {a, chars} , {b, chars}, {c, chars}]]];
Map [If[Get[encoded, #] === $Failed, , Print[#]] &, keys];

The output is usually 4 3-character keys that can be used to decode the package. They vary depending on the key that was given for encoding. I have tried it for other combinations such as 4 characters, 2 characters + digit and it gives other possible keys. It also produces the error (in the messages window): INTERNAL SELF-TEST ERROR: FileNotify|c|305

I am using Mathematica 10 - can anyone replicate this?

3 Replies

Hi E B,

I am not quite sure what your code is doing as it is not running on my computer like that. I have modified it and I hope that it is doing wha you are trying to achieve:

chars = CharacterRange["a", "z"];
keys = DeleteDuplicates[Flatten[Table[a <> b <> c, {a, chars}, {b, chars}, {c, chars}]]];
Quiet[Map[If[Decrypt[#, encoded] === $Failed, , Print[#]] &, keys]];

It does run quite a while, but only returns the one string I used to encrypt the data. (I ran it on a three letter string.)

Cheers, Marco

PS: The funny thing is that when I used ParallelMap to accelerate it, the code did not work.

POSTED BY: Marco Thiel
Posted 8 years ago


Sorry perhaps I should have provided an example input. I am not using Encrypt, just Encode and Get, as described in the documentation:

encoded = ToFileName[$TemporaryDirectory, "encoded"];
Encode["Test.m", encoded, "hq234*id&)R"]
Map[If[Get[encoded, #] === $Failed, , Print[#]] &, keys];

Output is


But it varies depending on the encoding key- maybe also on the package being encoded, I'm not sure.


That is quite curious. I only used:

encoded = Encrypt["abc", "This is a test."]

for my example and it seems to work fine. As you see I also used Decrypt in my program. I ran your program and can now reproduce that. It looks a bit funny indeed. It even "cracks" your complicated password with four simple three letter combinations.

If you run

chars = CharacterRange["a", "z"];
keys = DeleteDuplicates[
   Flatten[Table[a <> b <> c, {a, chars}, {b, chars}, {c, chars}]]];
encoded = ToFileName[$TemporaryDirectory, "encoded"];
Encode["~/Desktop/test.m", encoded, "abc"]
Map[If[Get[encoded, #] === $Failed, , Print[#]] &, keys];

it recovers the password but finds three additional ones that work. I am not sure whether this is the intended behaviour.



POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract