klaxit / hidden-secrets-gradle-plugin

🔒 Deeply hide secrets on Android
MIT License
395 stars 40 forks source link

String size issue #16

Closed dorozhans closed 3 years ago

dorozhans commented 3 years ago

Hey! I've faced the issue today. You can't encode String more than 4046 symbols (In my case it's a JSON configuration file). After using a function on the Java side I do not receive the initial String, only part of it. Could you explain why and If possible provide some workaround?

ben-j69 commented 3 years ago

Hi @dorozhans thanks for your message.

1/ Can you confirm me you succeed to get a smaller key without any issue ? 2/ I will investigate on large Strings to see what is possible to do. 3/ A possible workaround : separate your String in smaller Strings and then concat them ?

dorozhans commented 3 years ago
  1. Yes, confirmed.
  2. Thanks! :)
  3. Yes, I thought about that, but I've started to find an issue in C code, probably you provide a small buffer. Will review your code too.
ben-j69 commented 3 years ago

@dorozhans the issue does not appear to com from the Kotlin side, it can generate sha256 for 5000 characters string without any problem.

So it must be the C code as you thought, if you have any idea of a fix let me know (you can open PR).

We did not build this plugin to encode long files, but things like api keys. Can I ask you what is your use case that need to encode a full json file instead of obfuscated only the keys ?

dorozhans commented 3 years ago

I am receiving JSON string with configuration through the launching .sh script before app builds. Yes, it was a mistake in the C code. I will provide a PR a bit later.

ben-j69 commented 3 years ago

Hello @dorozhans .

I think I found the fix to your issue by solving issue #26

From my new test encoding 5000 characters is now working. The issue was in the sha256 in the c++.

Could you try this solution and tell me if it is also fixed for you please ?

From the PR : #21 you can update your project by copying into your files : insecrets.cpp function getOriginalKey in sha256.cpp function void sha256(const char* input, char buf[2*SHA256::DIGEST_SIZE + 1])

Thanks !

ben-j69 commented 3 years ago

Fixed in release 0.1.1