From 0bff7c259b915607757f21e2e6b94160f0b9401e Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 28 May 2017 23:16:42 -0400 Subject: Simplify int to hex string conversion (#3628) --- src/cryptography/hazmat/backends/openssl/backend.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py index 9900d053..412432df 100644 --- a/src/cryptography/hazmat/backends/openssl/backend.py +++ b/src/cryptography/hazmat/backends/openssl/backend.py @@ -331,9 +331,9 @@ class Backend(object): return bn_ptr else: - # Under Python 2 the best we can do is hex() - - hex_num = hex(num).rstrip("L").lstrip("0x").encode("ascii") or b"0" + # Under Python 2 the best we can do is hex(), [2:] removes the 0x + # prefix. + hex_num = hex(num).rstrip("L")[2:].encode("ascii") bn_ptr = self._ffi.new("BIGNUM **") bn_ptr[0] = bn res = self._lib.BN_hex2bn(bn_ptr, hex_num) -- cgit v1.2.3