Skip to content

Leading Zeroes Lost  #6

Closed
Closed
@hatgit

Description

@hatgit

When an n-bit number contains x-bits of leading zeroes and the decoder tries to map the Hatnotated string back to Binary, any leading zeroes are not showing in the final result.

Base-2 Binary Example (128 bits) with two leading zeroes: 00100110101101111110100111001011011001100011100100010001001001111011100011111010101110000101100010110000000111010010011100111110

Base-16 Hex: 0x26b7e9cb66391127b8fab858b01d273e
Base-10 Decimal Integer: 51465596081329778647712687587606734654
Base-64 Hatnotation: #*_$BPZ!H9}Z[+5Y-7IS_

All of the above three decode back binary with leading zeroes lost: 100110101101111110100111001011011001100011100100010001001001111011100011111010101110000101100010110000000111010010011100111110

Currently, the decoder is not showing leading zeroes as that information is not present when the Encoder computes the notation from a starting hex value. Perhaps starting with a binary string would help but this problem would persist and I don't think there is a method to resolve as those leading zeroes values are also lost when converting binary to other popular notation methods.

Potential consideration: Any software allowing access or recovery should only allow a fixed length character limit so that if a user pasted a value short of that limit it would be left-padded with leading zeroes.

Notes I had on this matter from last year: "even when no leading zero in string, the leading zeroes of the actual base64 character are discarded, as the encoding appears to happen from right to left, see this test string where leading zeroes of first character at index value 2 in the library are discarded, and last character is N 0xb13ae7e331ce9dfa59799e95ee8dc117 which decodes to 2.E+VZCS[T_""@$&N+ZS4N

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions