aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2017-05-28 23:16:42 -0400
committerPaul Kehrer <paul.l.kehrer@gmail.com>2017-05-28 22:16:42 -0500
commit0bff7c259b915607757f21e2e6b94160f0b9401e (patch)
treec3b571f4649633e5494c50b8f1496d7e689025de /src
parente4318ea34e34241e7bcda489325ba1a51054ada5 (diff)
downloadcryptography-0bff7c259b915607757f21e2e6b94160f0b9401e.tar.gz
cryptography-0bff7c259b915607757f21e2e6b94160f0b9401e.tar.bz2
cryptography-0bff7c259b915607757f21e2e6b94160f0b9401e.zip
Simplify int to hex string conversion (#3628)
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py6
1 files changed, 3 insertions, 3 deletions
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)