According to this question, validFor="AAAI"
should translate to 000000 000000 000000 001000
.
With the following function I get 10000010100000101000001010010010
however. What is the problem?
def salesforce_decode_valid_for(valid_for: str):
bits = bytearray(valid_for.encode('utf-8'))
result = []
for byte in bits:
for i in range(8):
result.append(bool(byte & (1 << i)))
return ''.join(['1' if flag else '0' for flag in result])