Use byte literals in examples and unit tests
In Python 2.x an unprefixed string literal produces a byte string. In Python 3.x an unprefixed string literal produces a textual string. To produce a byte string in both a b prefix is needed, e.g. b'foo'. Since I believe Hammer works predominantly with byte strings I have used b prefixes throughout.
This commit is contained in:
parent
8b4b8ddc57
commit
59ba68ef84
4 changed files with 203 additions and 203 deletions
|
|
@ -36,9 +36,9 @@ def bsfdig_value(p):
|
|||
return c - 0x61 + 26
|
||||
elif 0x30 <= c <= 0x39: # 0-9
|
||||
return c - 0x30 + 52
|
||||
elif c == '+':
|
||||
elif c == b'+':
|
||||
return 62
|
||||
elif c == '/':
|
||||
elif c == b'/':
|
||||
return 63
|
||||
return 0
|
||||
|
||||
|
|
@ -109,16 +109,16 @@ def init_parser():
|
|||
# CORE
|
||||
digit = h.ch_range(0x30, 0x39)
|
||||
alpha = h.choice(h.ch_range(0x41, 0x5a), h.ch_range(0x61, 0x7a))
|
||||
space = h.in_(" \t\n\r\f\v")
|
||||
space = h.in_(b" \t\n\r\f\v")
|
||||
|
||||
# AUX.
|
||||
plus = h.ch('+')
|
||||
slash = h.ch('/')
|
||||
equals = h.ch('=')
|
||||
plus = h.ch(b'+')
|
||||
slash = h.ch(b'/')
|
||||
equals = h.ch(b'=')
|
||||
|
||||
bsfdig = h.choice(alpha, digit, plus, slash)
|
||||
bsfdig_4bit = h.in_("AEIMQUYcgkosw048")
|
||||
bsfdig_2bit = h.in_("AQgw")
|
||||
bsfdig_4bit = h.in_(b"AEIMQUYcgkosw048")
|
||||
bsfdig_2bit = h.in_(b"AQgw")
|
||||
base64_3 = h.repeat_n(bsfdig, 4)
|
||||
base64_2 = h.sequence(bsfdig, bsfdig, bsfdig_4bit, equals)
|
||||
base64_1 = h.sequence(bsfdig, bsfdig_2bit, equals, equals)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue