opaque-id icon indicating copy to clipboard operation
opaque-id copied to clipboard

Obfuscate 64-bit integers

Open cerbero90 opened this issue 3 years ago • 2 comments

Hello and thank you for this great package :)

I tried to leverage it with 64-bit integers but I'm not expert enough with bitwise operations to make it work, any suggestions on how this would be possible?

Thank you in advance :)

cerbero90 avatar Mar 08 '21 09:03 cerbero90

Also there are 2 questions I'd like to ask you:

  1. why are we multiplying the salted integer by 0x9e3b in transform()?
  2. we are keeping only the first 6 characters of the base64 encoded binary, what makes this algorithm work without the full base64 string?

Thank you for your time ❤️

cerbero90 avatar Mar 08 '21 10:03 cerbero90

I ended up with this solution: https://gist.github.com/cerbero90/fb99f79570c413a05c5efa5aab6dd72e it supports 32bit and 64bit integers but does not support negative integers, feedback is more than welcome :)

Regarding the question 2, base64 representation is enough to cover all 32bit integers with 6 characters, so we can safely remove the extra = symbols (correct me if I'm wrong).

Re question 1, I still haven't understood why we multiply by 0x9e3b

cerbero90 avatar Mar 09 '21 04:03 cerbero90