2025-04-19 22:35:35 -07:00
2025-04-19 22:35:35 -07:00
2025-04-19 22:35:35 -07:00
2025-04-19 21:42:36 -07:00
2025-04-19 22:35:35 -07:00
2025-04-19 22:35:35 -07:00
2025-04-19 22:35:35 -07:00

encrypted-tables

Operate an ordered sequence of dicts (referred here as a table) in the command line, and store them in the filesystem.

Description

Currently, we support base64 encoded (no encryption) or the fernet symmetric entryption algorithm.

Warning: Storing in base64 format without encryption provides a false sense of security and should be avoided, it is kept for backward compatibility only.

The symmetric key is obtained by a key derivation function taking your password and a randomly-generated salt as input.

I don't know why anyone would need this, why not use a database?

How to run

Environment: Python 3.8 (other versions might work as well), cryptography==39.0.1

Basic usage

1.Create a new table

python peek.py example fernet --create. You will be prompted to enter a password for this table first.

The "table" in this program is different from the table in the database sense, it is an ordered sequence of rows, where each row is a dictionary (collection of key-value pairs).

2. Add data rows and printing the table

Enter kv pairs to initialize / add a row. Use command 'a' to add row and 'p' to print rows.

>a
k:name
v:alice
k:sport
v:skiing
k:
>a
k:name
v:bob
k:sport
v:cycling
k:
>p
0
name:alice  sport:skiing
1
name:bob    sport:cycling

3. Modify a row / delete a row

Use command 'm' to modify a row (add new kv pairs or overwrite existing kv pairs); use 'd' to delete a row by its current index in the table.

>m
index:1
k:lang
v:en
k:
>d
index:0
deleting 1:name:alice   sport:skiing
>p
0
name:bob    sport:cycling   lang:en

4. Saving, quitting, and reopening

Use the command 'wq' to save and quit, 'q!' to discard changes and quit.

>wq
# python peek.py example fernet
password:<yourpassword>
>p
name:bob    sport:cycling   lang:en

Using shortcuts

Key names must have at least 2 characters; you can setup and use single-character shortcuts to refer to the key name.

Defining shortcuts

Use 'sc' to define shortcuts; Running this command will overwrite all existing shortcuts, you must exit and re-enter the program for the shortcut to take effect.

>sc
{}
k:n
v:name
k:s
v:sport
k:
>wq

Using shortcuts

You can use shortcuts to add rows more efficiently.

>a
k:n
v:carol
k:s
v:swimming

Format print using shortcuts

You can print the table in the format specified using the command 'f'. It prints an table with the keys ordered by the string you give (use shortcut to represent keys); only rows that have all the keys available will be printed. use '+' to print any additional keys in each row.

>f
ns
|#|name|sport|
|---|---|---|
|0|bob|cycling|
|1|carol|swimming|
>f
keys:sn+
|#|sport|name|+|
|---|---|---|---|
|0|cycling|bob|lang:en;|
|1|swimming|carol||
Description
Operate an ordered sequence of dicts, referred here as a table, in the command line and store them (optionally encrypted) on the filesystem.
Readme MIT 30 KiB
Languages
Python 100%