Skip to content

Secret key in Aead and/or SecretBox #833

@ConYel

Description

@ConYel

I would like to use pynacl in a project in which I want to encrypt a url.
I would like to provide back the key of the encryption but I see that it cannot be decoded back with utf-8.

import nacl.secret
import nacl.utils
key = nacl.utils.random(nacl.secret.Aead.KEY_SIZE)
box = nacl.secret.Aead(key)
key.decode('utf-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 1: invalid start byte

How is it possible to decode the key in a "readable" format that can be copy pasted easily?
Maybe my approach is not correct and I should be using something different?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions