Esempio n. 1
0
def new(title):
    """Create a new note."""
    try:
        note = Note.create(title)
    except FileExistsError:
        echo_error('This note already exists!')
        exit(1)
    content = click.edit(note.content.decode(), editor=config.EDITOR)
    note.content = content.encode() if content else ''
Esempio n. 2
0
def encrypt(ctx, key, password):
    note = get_note(ctx.data, key)

    aes_key = crypt.password_digest(password)
    ciphertext = crypt.encrypt(note.content, aes_key)
    encrypted_note = Note.create(note.title, encrypted=True)

    # TODO: Refacator this out, see container.Note
    with encrypted_note.path.open('bw') as f:
        f.write(ciphertext)