Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if args.length != None:
k = NumUtils.pow2_round(args.length)
if args.hex:
try:
cleartexts = [unhexlify(cleartext) for cleartext in cleartexts]
except TypeError as te:
print("Cleartext provided is not in hex format: %s: " % cleartext, te, file=stderr)
parser.print_help()
exit(1)
pkcs1 = PKCS1_v15(k)
for m in cleartexts:
for i in tests:
padded_cleartext = getattr(pkcs1, PKCS1_v15.FUNC_TABLE[i])(m)
if print_encrypted:
c = rsa.encrypt(padded_cleartext, 0)[0]
c = "\x00"*(k/8-len(c)) + c
print(hexlify(c))
else:
print(hexlify(padded_cleartext))