Commit 6ac5412d by Scott Duckworth

use binascii.hexlify() in bytes2int()

parent fa9b8154
......@@ -27,6 +27,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import base64
import binascii
import struct
SSHKEY_LOOKUP_URL_DEFAULT = 'http://localhost:8000/sshkey/lookup'
......@@ -52,13 +53,8 @@ def wrap(text, width, wrap_end=None):
n = m
return t
def bin2hex(data):
return ''.join('%02x' % struct.unpack('B', b) for b in data)
hex2bin = bytearray.fromhex
def bytes2int(b):
h = ''.join('%02x' % struct.unpack('B', x) for x in b)
h = binascii.hexlify(b)
return int(h, 16)
def int2bytes(i):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment