Created
November 9, 2023 21:08
-
-
Save WellingtonEspindula/f2a2ca9f9a30fbe6ba9a82428b94bfb1 to your computer and use it in GitHub Desktop.
Rotate x times chars (using unsigned char) in a byte string (useful to desobfuscate secrets in C code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def rotate(byte_string, x_times): | |
| return "".join( [ chr( (byte + x_times) % 256) for byte in memoryview(byte_string).tolist()]) | |
| # exemple | |
| rotate(b'\x74\x66\x75\x66\x64\x62\x74\x75\x73\x70\x6f\x70\x6e\x7a\x00', 0xff) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment