Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from __future__ import unicode_literals
- import binascii
- def encode_hexlify(origin_text, encoding='utf-8'):
- """
- function to simply encode the text string using hexlify.
- :param `origin_text` is string original text to encode.
- :param `encoding` is encode mode.
- :return string of encoded text.
- """
- byte = bytes(origin_text, encoding)
- return binascii.hexlify(byte).decode(encoding)
- def decode_hexlify(encoded_text, encoding='utf-8'):
- """
- function to simply decode the text string using hexlify.
- :param `encoded_text` is string encoded text to decode.
- :param `encoding` is encode mode.
- :return string of decoded text.
- """
- byte = bytes(encoded_text, encoding)
- return binascii.unhexlify(byte).decode(encoding)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement