Skip to main content

terpinkb

terpinkb is a small Textual package for collecting PINs or short secrets with a randomized on-screen keyboard. It is designed for applications that want to avoid sending secret characters through the physical keyboard input path.

Threat Model

This component helps with keyboard-channel avoidance. Users choose characters by mouse or by non-secret keyboard navigation such as Tab, arrow keys, Enter, Backspace, Escape, Shift, Caps, and palette switching.

It does not make secret entry safe on a compromised host, compromised terminal emulator, compromised Python process, screen scraper, memory inspector, hostile shell, terminal escape injection path, or malware that observes mouse events or process memory.

Features

  • Native Textual ModalScreen.
  • Randomized character buttons.
  • Locale-aware default palettes with letters, numbers, punctuation, and symbols.
  • On-screen Shift, Caps, Space, Backspace, Clear, Shuffle, OK, and Cancel.
  • Optional coarse policy and strength/status display.
  • PinResult returns bytes and supports explicit in-place destruction.

Installation

pip install -e ".[dev]"

The preferred local workflow uses uv:

uv venv
uv pip install -e ".[dev]"
uv run pytest
uv run ruff check .
uv run mypy src

Usage

from textual.app import App, ComposeResult
from textual.widgets import Button

from terpinkb import RandomizedPinModal, PinResult


class DemoApp(App):
    def compose(self) -> ComposeResult:
        yield Button("Enter Secret", id="enter-secret")

    def on_button_pressed(self, event: Button.Pressed) -> None:
        if event.button.id == "enter-secret":
            self.push_screen(
                RandomizedPinModal(secret_length=6),
                self.handle_secret_result,
            )

    def handle_secret_result(self, result: PinResult | None) -> None:
        if result is None:
            self.notify("Secret entry canceled")
            return

        try:
            secret_bytes = result.consume()
            # Verify immediately, then drop application-side references.
        finally:
            result.destroy()

Demo

python examples/demo.py

The demo shows only masked receipt status. It never prints or displays the secret itself.

Testing

pytest
ruff check .
mypy src

Release

Build and validate distribution artifacts locally:

python -m build
twine check dist/*

Publishing is configured through GitHub Actions and PyPI Trusted Publishing. To publish a release, configure the akarasulu/terpinkb repository as a trusted publisher for the terpinkb PyPI project, then publish a GitHub release. The release workflow will test, build, validate, and upload the package to PyPI.

Policy And Strength

SecretPolicy can enforce simple metadata-based requirements such as minimum length or requiring a digit. These rules are optional and disabled by default. Strength/status text is deliberately coarse and advisory. It is not a cryptographic guarantee and is less useful for short fixed PIN workflows or HSM PINs with device retry counters.

HSM PINs

terpinkb may be used to collect an HSM, smart-card, token, or PKCS#11 PIN when the embedding application can pass the returned bytes directly to its HSM library or middleware. Do not pass the PIN in command-line arguments, environment variables, config files, logs, or external prompts. Respect device retry counters and lockout behavior, and let the embedding application handle vendor-specific PIN formats.

Security Caveats

Python cannot guarantee complete memory secrecy. PinResult.destroy() overwrites the package-owned bytearray, but immutable bytes copies returned to the caller cannot be wiped by this package. Verify immediately and drop references as soon as possible.

Metadata

Release files for terpinkb 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for terpinkb 0.1.0
File Size Uploaded Provenance
terpinkb-0.1.0.tar.gz 15.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for terpinkb 0.1.0
File Interpreter ABI Platform
terpinkb-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.4 kB

Release files / terpinkb-0.1.0.tar.gz

Download URL terpinkb-0.1.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c33620160be399144f281b1322e90c1f1e532e5b937c50486a24496a8ec04c86
BLAKE2b-256 checksum
How to use checksums
07c7d79a339a48df96a2a789daa3d0fb6376927ba14befcb2bc3f99e7544deb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 23, 2026.

Transparency log

Release files / terpinkb-0.1.0-py3-none-any.whl

Download URL terpinkb-0.1.0-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7b40bf86adcf166e15992c0e566fd69ac82c206156000edc8d3b5e6676a04fe
BLAKE2b-256 checksum
How to use checksums
f5a7e3b006678ca5744ce54e7cfba573465be47a73d7b9ebbb798902b1645277
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 23, 2026.

Transparency log

Security for terpinkb 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for terpinkb-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page