Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def benchmark(args):
print(__package__ + ' ' + pybase64.get_version())
data = readall(args.input)
for altchars in [None, b'-_']:
for validate in [False, True]:
print('bench: altchars={0:s}, validate={1:s}'.format(
repr(altchars), repr(validate)))
bench_one(args.duration,
data,
pybase64.b64encode,
pybase64.b64decode,
pybase64.encodebytes,
altchars,
validate)
bench_one(args.duration,
data,
base64.b64encode,
b64decodeValidate,
b64encodebytes,
altchars,
validate)
def process_message(message):
try:
deflated_msg = decompress(b64decode(message, validate=True), -MAX_WBITS)
except SyntaxError as e:
deflated_msg = decompress(b64decode(message, validate=True))
except TypeError:
# Python2 doesn't have validate
deflated_msg = decompress(b64decode(message), -MAX_WBITS)
return loads(deflated_msg.decode())
def decode(args):
data = readall(args.input)
data = pybase64.b64decode(data, args.altchars, args.validate)
writeall(args.output, data)
async def process_message(message):
try:
deflated_msg = decompress(b64decode(message, validate=True), -MAX_WBITS)
except SyntaxError:
deflated_msg = decompress(b64decode(message, validate=True))
return loads(deflated_msg.decode())
def process_message(message):
try:
deflated_msg = decompress(b64decode(message, validate=True), -MAX_WBITS)
except SyntaxError as e:
deflated_msg = decompress(b64decode(message, validate=True))
except TypeError:
# Python2 doesn't have validate
deflated_msg = decompress(b64decode(message), -MAX_WBITS)
return loads(deflated_msg.decode())