Audible
Audible copied to clipboard
Multiple fixes for XXTEA encryption/decryption in metadata module
-
Use math.ceil instead of ldata when calculating ldata, otherwise encryption could sometimes result in invalid output, decryption could sometimes fail as well.
-
Use math.floor instead of int in raw_xxtea, mainly for readability and parity with Amazon's xxtea implementation.
-
Use metadata[9:] instead of metadata.lstrip("ECdITeCs:") when removing the metadata header, otherwise decryption fails when either of the aforementioned letters ("ECdITeCs:") appear as prefix in the metadata string (as lstrip works per letter in the string passed as a parameter, not for the entire string).
-
Modified order of calculation in decrypt_metadata so it is exactly the reverse of the actions done in encrypt_metadata.
-
Changed naming of variables in encrypt_metdata and decrypt_metadata so they better reflect their content, as well as keeping consistency in naming between the two aforementioned functions.