Metadata-Version: 2.4
Name: mshesh
Version: 0.1.0
Summary: mshesh // a tiny hash terminal with random hashes, value hashes, and a jittered monitor
Author: tderk
License-Expression: MIT
Keywords: hash,sha256,terminal,monitor,logging,cli
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Terminals
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: pytest>=7; extra == "dev"
Dynamic: license-file

# mshesh

`mshesh` is a small terminal hash app. It asks for a username, then drops you
into a hash terminal:

- press **Enter on an empty line** → a fresh random hash;
- type **any text** → the SHA-256 hash of exactly that text;
- run **monitor mode** → hashes appear at randomized intervals;
- **record** every hash live, **save the whole log**, or **save only the last
  N lines**;
- **translate** any hash into 24 BIP39 words with `/words`.

Hashes are 64 lowercase hex characters (SHA-256 output for value hashes and a
32-byte `secrets` token for random hashes).

## Install

From this folder:

```bash
python3 -m pip install .
```

For development:

```bash
python3 -m pip install -e ".[dev]"
```

This installs the `mshesh` command. You can also run it without installing:

```bash
PYTHONPATH=src python3 -m mshesh
```

## Usage

```bash
mshesh
```

```text
username: kredt
mshesh 0.1.0 | hash terminal
user: kredt | log: /home/kredt/mshesh-log.txt
Enter = random hash | text = hash of text | /help for commands
kredt@mshesh> 
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08  sha256  [random]
kredt@mshesh> hello
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824  sha256  [value=hello]
```

Use `//text` when you want to hash text that itself begins with a slash.

Print several random lines at once (all random, all logged):

```text
kredt@mshesh> /random 3
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08  sha256  [random]
...
```

### Commands

| Command | What it does |
| --- | --- |
| `/monitor [i] [chance] [n]` | Monitor mode. `i` is the standard interval in seconds, `chance` is an integer 0–100, `n` is an optional tick limit. `Ctrl+C` stops. |
| `/random N` | Print `N` random hash lines. They are also added to the log and any active recording. |
| `/words [N]` | Encode the latest hash, or the last `N` hashes, as 24 BIP39 words each. |
| `/record [path]` | Start (or keep) live recording of every new hash to a text file. Default: `./mshesh-record.txt`. |
| `/record off` | Stop live recording. |
| `/save [path]` | Save the whole in-memory log. Default: `./mshesh-log.txt`. |
| `/save-lines N [path]` | Save only the last `N` lines of the log. |
| `/log [N]` | Show the whole log or only its last `N` lines. |
| `/user [name]` | Show or change the username. |
| `/status` | Show user, hash count, log path, and recording path. |
| `/help` | Show command help. |
| `/quit` | Leave the terminal (`Ctrl+D` also works). |

Log and recording lines are pipe-delimited:

```text
2026-11-25T03:04:05 | kredt | value=hello | 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
2026-11-25T03:04:09 | kredt | random | 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
```

## Monitor mode

```bash
mshesh --monitor --interval 5 --value-chance 60
```

or from inside the terminal:

```text
kredt@mshesh> /monitor 5 60
monitor: every ~5s | value chance 60% | Ctrl+C to stop
```

The **standard monitoring time** is `5.0` seconds. Each delay is jittered
between 60% and 140% of that value, so the monitor never beats at a perfectly
fixed rate.

The integer `value_chance` (0–100) decides, per tick, whether that particular
instance supplies a value:

- **value supplied** → hash of a word from the built-in value pool, plus an
  extra randomized half-interval delay (more time randomization);
- **no value** → a random hash.

`0` means "always random"; `100` means "always hash a supplied value".
`/monitor 5 60 10` runs ten ticks and stops by itself.

## Word encoding

`/words` turns a 256-bit hash into a standard BIP39 phrase of 24 English
words. `/words N` does it for the last `N` hashes.

```text
kredt@mshesh> /words
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824  [value=hello]
  coconut mystery hub satoshi any mandate option alter client column judge
  destroy ramp august idea visual drastic vicious scissors grocery circle
  shift gauge naive
```

This is an **encoding**, not decryption. The 24 words decode back to the exact
hash, but they cannot reveal `hello` — SHA-256 is still one-way. Random hashes
never had an input value to begin with.

The wordlist is the official BIP39 English list from
[bitcoin/bips](https://github.com/bitcoin/bips) (MIT).

## Library use

```python
from mshesh import Session, digest_to_phrase, hash_value, run_monitor

session = Session("kredt", record_path="live.txt")

session.add()             # random hash
session.add("hello")      # deterministic hash of "hello"
session.add_random(5)     # five random hashes

print(digest_to_phrase(hash_value("hello")))  # 24 BIP39 words

session.save("whole-log.txt")
session.save("tail-log.txt", lines=20)

run_monitor(session, interval=5.0, value_chance=50, ticks=10)
```

`run_monitor` also accepts `values=` (the value pool), `rng=`, `sleep=`, and
`emit=` hooks, which makes it easy to test or embed.

## Development

```bash
python3 -m unittest discover -s tests -v
```

## License

MIT
