pyca / pyca/pynacl

Secret key in Aead and/or SecretBox

Open
#833 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.2k
Forks
267
Avg merge
42m
Merged PRs (30d)
2

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the nacl.secret.Aead and SecretBox APIs and the nacl.utils.random entry point mentioned in the report. Clarify the documented handling of generated keys and identify the appropriate user-facing guidance for copying or storing them; done means the usage question is answered unambiguously in the relevant documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cryptography
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.