diff options
| author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-10-25 15:44:29 -0500 |
|---|---|---|
| committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-10-26 08:27:22 -0500 |
| commit | 467072f7d50778f064f192b4e318c19c6cf98293 (patch) | |
| tree | 9ef70c8cf76f86795f05fc00d22b9db785b9e659 /src/cryptography/utils.py | |
| parent | 9bbf778b7dde2fab6d957f3b5b4422d5bb3ce5a0 (diff) | |
| download | cryptography-467072f7d50778f064f192b4e318c19c6cf98293.tar.gz | |
add support for encoding/decoding elliptic curve points
Based on the work of @ronf in #2346.
Diffstat (limited to 'src/cryptography/utils.py')
| -rw-r--r-- | src/cryptography/utils.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py index dac4046de..dbd961f78 100644 --- a/src/cryptography/utils.py +++ b/src/cryptography/utils.py @@ -48,9 +48,12 @@ else: return result -def int_to_bytes(integer): +def int_to_bytes(integer, length=None): hex_string = '%x' % integer - n = len(hex_string) + if length is None: + n = len(hex_string) + else: + n = length * 2 return binascii.unhexlify(hex_string.zfill(n + (n & 1))) |
