c,python: Use little-endina byte order for bigint arithmetics
This better matches what one would expect from the hex or base64 (upcoming) formats.
This commit is contained in:
@ -21,7 +21,7 @@ class Bhash:
|
||||
"""
|
||||
Initialize a Bhash from a bytes object
|
||||
"""
|
||||
self.bhash = int.from_bytes(buf, byteorder='big')
|
||||
self.bhash = int.from_bytes(buf, byteorder='little')
|
||||
self.bits_avail = len(buf) * 8
|
||||
self.bits_used = 0.0
|
||||
|
||||
|
||||
@ -12,11 +12,11 @@ import argparse
|
||||
PHO_GEN_VOWELS = "aeiou"
|
||||
|
||||
PHO_GEN_TEST = [
|
||||
[ b"passgeny", "herang xiasem zitend qibele" ],
|
||||
[ b"phonetic", "lineum foneum zybale mangur" ],
|
||||
[ b"generator", "latole elitab ackina exprou" ],
|
||||
[ b"password", "nulize nomere fonici crednt" ],
|
||||
[ b"duck", "catabb rompor cricin prunsi" ] ]
|
||||
[ b"passgeny", "vatome iddeda pashis artarc" ],
|
||||
[ b"phonetic", "joredl qibini kninet ouslis" ],
|
||||
[ b"generator", "vormul zilyth disedl chryso" ],
|
||||
[ b"password", "wompot ficara uplort lancon" ],
|
||||
[ b"duck", "inerea iricin ovusia irrisi" ] ]
|
||||
|
||||
|
||||
PYTHON_HEADER = """#
|
||||
@ -57,7 +57,7 @@ class HashInt:
|
||||
self.bits_used = 0
|
||||
|
||||
def from_bytes(self, buf):
|
||||
self.hash = int.from_bytes(buf, byteorder='big')
|
||||
self.hash = int.from_bytes(buf, byteorder='little')
|
||||
self.bits = len(buf) * 8
|
||||
|
||||
# Divide the HashInt by `idiv` and return the modulo
|
||||
|
||||
Reference in New Issue
Block a user