Message Boards Message Boards

3
|
5448 Views
|
3 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Encode/Decode bug?

Posted 9 years ago

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?

POSTED BY: E B
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 9 years ago

Hi,

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

aby
hjb
imp
qxg

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

POSTED BY: E B

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.

Cheers,

Marco

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

Group Abstract Group Abstract