How to use the libnacl.encode.hex_encode function in libnacl

To help you get started, we’ve selected a few libnacl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github saltstack / libnacl / libnacl / base.py View on Github external
def hex_seed(self):
        if hasattr(self, 'seed'):
            return libnacl.encode.hex_encode(self.seed)
github saltstack / libnacl / libnacl / base.py View on Github external
def hex_pk(self):
        if hasattr(self, 'pk'):
            return libnacl.encode.hex_encode(self.pk)
github Tribler / dispersy / crypto.py View on Github external
def __init__(self, binarykey="", pk=None, hex_vk=None):
        if binarykey:
            pk, vk = binarykey[:libnacl.crypto_box_SECRETKEYBYTES], binarykey[libnacl.crypto_box_SECRETKEYBYTES: libnacl.crypto_box_SECRETKEYBYTES + libnacl.crypto_sign_SEEDBYTES]
            hex_vk = hex_encode(vk)

        self.key = libnacl.public.PublicKey(pk)
        self.veri = libnacl.sign.Verifier(hex_vk)
github saltstack / libnacl / libnacl / base.py View on Github external
def hex_vk(self):
        if hasattr(self, 'vk'):
            return libnacl.encode.hex_encode(self.vk)
github Tribler / py-ipv8 / ipv8 / keyvault / public / libnaclkey.py View on Github external
def __init__(self, binarykey="", pk=None, hex_vk=None):
        """
        Create a new LibNaCL public key. Optionally load it from a string representation or
        using a public key and verification key.

        :param binarykey: load the pk from this string (see key_to_bin())
        :param pk: the libnacl public key to use in byte format
        :param hex_vk: a verification key in hex format
        """
        # Load the key, if specified
        if binarykey:
            pk, vk = (binarykey[:libnacl.crypto_box_SECRETKEYBYTES],
                      binarykey[libnacl.crypto_box_SECRETKEYBYTES: libnacl.crypto_box_SECRETKEYBYTES
                                + libnacl.crypto_sign_SEEDBYTES])
            hex_vk = libnacl.encode.hex_encode(vk)
        # Construct the public key and verifier objects
        self.key = libnacl.public.PublicKey(pk)
        self.veri = libnacl.sign.Verifier(hex_vk)
github lgrahl / threema-msgapi-sdk-python / threema / gateway / key.py View on Github external
Encode a key.

        Arguments:
            - `libnacl_key`: An instance of either a
              :class:`libnacl.public.SecretKey` or a
              :class:`libnacl.public.PublicKey`.

        Return the encoded key.
        """
        # Detect key type and hexlify
        if isinstance(libnacl_key, libnacl.public.SecretKey):
            type_ = Key.Type.private
            key = libnacl_key.hex_sk()
        elif isinstance(libnacl_key, libnacl.public.PublicKey):
            type_ = Key.Type.public
            key = libnacl.encode.hex_encode(libnacl_key.pk)
        else:
            raise GatewayKeyError('Unknown key type: {}'.format(libnacl_key))

        # Encode key
        return Key.separator.join((type_.value, key.decode('utf-8')))
github duniter / duniter-python-api / duniterpy / tools.py View on Github external
def convert_seed_to_seedhex(seed: bytes) -> str:
    """
    Convert seed to seedhex

    :param seed: seed
    :rtype str:
    """
    return hex_encode(seed).decode("utf-8")
github saltstack / libnacl / libnacl / base.py View on Github external
def hex_sk(self):
        if hasattr(self, 'sk'):
            return libnacl.encode.hex_encode(self.sk)
        else:
            return ''