Copy protected dictionary source data

Started by jn0101, 25. April 2010, 20:41:12

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jn0101


I have a Danish dictionary which I'd like to publish, but the author agreement is that it MUST be copy protected (so of course you can't have that on SF and probably you don't want to host it at all), with some kind of encryption (a weak one, like the Roman onee where you swap a->b, b->c, c->d etc etc would be OK, we all know that copy protection is a farce anyway).

It this something you would be willing to help with or give advise on?

Jacob

Gert

Jacob,

DfM had a 'weak encryption' feature in its very early days. But I dropped it, mainly cause it was really weak (just calling the right class/method would have done the decryption) and I did not want to overload the toolset with an encryption option.

It would be possible to re-introduce such a weak encryption again ... but me I am right now really short on time.

Besides, by now there are APIs for Java ME (and I assume also Android) that support a 'strong encryption'.

Regards,
Gert

jn0101

Thanks for the reply, Gert.

My need is something simple which would still allow to easily publish the dictionary as a MIDlet and as an Android app (and iPhone, but thats probably not gonna happen).

So your old 'mild encryption' code would be fine as the same code and the same data could be used for both versions. I'm a Java developer myself, if you direct me to the right pieces then I might just do it myself, at a later time, if the code could remain in the trunk for future versions.

Any encryption strong or not, could be broken with a debugger and some skills. The intent is just to block people from simply importing the .csv files into a spreadsheet.

I'll return to this subject at a later time, when we both have time.

Yours,
Jacob

jn0101

OK, Ive done the encryption:

public class DictionaryGeneration {
...
+
+        if ("weakCrypt".equals(DictionaryDataFile.fileEncodingFormat)) {
+          directoryOutput = weakEncrypt(directoryOutput);
+        }
+


+  /**
+   * Very weak encrytion/decryption mechanism
+   */
+  private static String weakEncrypt(String directoryOutput) {
+    StringBuilder res = new StringBuilder(directoryOutput.length());
+    for (char ch : directoryOutput.toCharArray()) {
+        char ch0 = ch;
+        if (ch>=60 && ch<124) ch = (char) (((ch-60)^'+') + 60);
+        res.append(ch);
+        //if (ch>=60 && ch<124) ch = (char) (((ch-60)^'+') + 60);
+        //if (ch0 != ch) throw new InternalError(directoryOutput + ch0 + ch);
+    }
+    return res.toString();
+  }
+
}


and in DictionaryForMIDs/src/de/kugihan/dictionaryformids/translation/Translation.java

@@ -517,7 +517,11 @@
                 indexLanguage < DictionaryDataFile.numberOfAvailableLanguages;
                 ++indexLanguage) {
                        StringBuffer word = dictionaryFile.getWord();
-                       
+
+        if ("weakCrypt".equals(DictionaryDataFile.fileEncodingFormat)) {
+          weakDecrypt(word);
+        }
+
...


+
+  /**
+   * Very weak encrytion/decryption mechanism
+   */
+  private static void weakDecrypt(StringBuffer word) {
+    int n = word.length();
+    while (--n>=0) {
+        char ch = word.charAt(n);
+        if (ch>=60 && ch<124) word.setCharAt(n, (char) (((ch-60)^'+') + 60));
+    }
+  }
+
+

This gives dictionary files like
URIR<<>Y        @TWTUBJUT
URIR<<>YB       UTMJ @TUXOYNJ?T/@TUXOYNJĵT
URIR<<>O        ĵNX@TUXOYNBOJ
URIR<UBU<       UTMJ @TUXOYNJĵT/@TUXOYNJ?T
UR?JUU>WX>      UTMJĵT, ĵNX@Y>BOJĵT, UTMJ =TYVBĝT
UR?JUU>O        ĵNX @Y>BOJ, UTM> =TYVBĝBUOJ

which is perfect for me.


So, if the field fileEncodingFormat is set to "weakCrypt" the encryption kicks in.

Any comments/suggestions/objections ?

Jacob

Gert


jn0101


jn0101

Argh, I will have to change the encryption. The author played with breaking encryption, unfortunately, and thinks its too easy :-(

I trust noone has actually used the weakCrypt and I can just change the implementation.

Jacob

jn0101

Ok, I changed the implementation, now there is an encryption password, which will make it an order of magnitude harder to break encryption.

Gert, could you please send me a DictionaryForMIDs_3.5.0_empty.zip compiled with these changes ?

It seems that my own version cannot handle the large files in my emulator (I get a OutOfMemoryError), but your obfuscated version runs file.

Thanks,
Jacob

Gert

I built 3.5.1 here: http://www.kugihan.de/dict/download/test_versions/3.5.1/DictionaryForMIDs_3.5.1_empty.zip

This is a 'blind build' out of the ant file (means, I did not test it).

Regards,
Gert

jn0101

Evrything works fine with your 3.5.1 build, Gert. I think I more or less finished my work.

Achim, I'd like to distribute this dictionary on the Android market.

What I imagine is that I just publish your app on the market as "Danish Esperanto dictionary" and then makes it download that dict to the SD card. I know, I could ask people to search for DfM, install, download Danish Esperanto dictionary to SD card, open it from the app etc, but thats gonna make a lot of people stop in vain.

It also makes sense for people searching the market for 'Esperanto' to see the 'dictionary' and install it.
That its not really the 'dictionary' that they install but a program that downloads a dictionary and shows it, probably doesent matter for most.

In general, Achim, I can see others are practicing publishing the same app several times with different language data. This makes sense from a user searching for dictionary apps for a specific language. So, I suggest you either mention all the languages in the app description, or consider poblishing several 'apps'.


Jacob