Skip to main content

mukimov

A small cross-platform Python library with masked password input and ANSI terminal colors.

PyPI version Python versions License: MIT Platform

Developed by Mukimov Studio

  • ⭐ Hidden password input with stars()
  • 🎨 12 terminal colors with mukimov.color

What is mukimov?

mukimov lets you read a password or any other secret text in the terminal while showing a mask character instead of the real keystrokes.

For example, the user really types:

123456

but the terminal shows:

Password: ******

And the function returns the real text "123456".

Starting with mukimov 0.1.4, the library also provides mukimov.color with 12 terminal colors — see the Colors sections below.

Important: this is NOT hashing and NOT encryption. The library only visually hides input from people who may be looking at the screen. The real password is still returned to your program as a plain string.

Installation

pip install mukimov

Upgrade to the latest version:

pip install --upgrade mukimov

Check the installed version:

pip show mukimov

Quick Start

The simplest possible example:

from mukimov import stars

password = stars("Password: ")

What the user sees:

Password: ******

If the user typed 123456, the variable password contains:

"123456"

Custom Mask ✨

The second argument controls which character is shown for every typed symbol:

stars("Password: ", "*")  # Password: ******
stars("Password: ", "/")  # Password: //////
stars("Password: ", "#")  # Password: ######
stars("Password: ", "•")  # Password: ••••••

API:

stars(prompt, mask="*")
Parameter Type Description
prompt str Text displayed before input.
mask str Character shown instead of each typed symbol. Defaults to "*".

Important: mask must contain exactly ONE character.

Full Example

A realistic login prompt:

from mukimov import stars

username = input("Username: ")
password = stars("Password: ")

print(f"Welcome, {username}!")

Example terminal session:

Username: Mukimov
Password: ********
Welcome, Mukimov!

Note that the real password is never printed — only the mask is shown.

Colors 🎨

Available since mukimov 0.1.4.

mukimov.color provides 12 terminal colors for your CLI output.

Установка актуальной версии:

pip install -U mukimov

Простой пример:

from mukimov.color import red, green, blue

print(red("Error"))
print(green("Success"))
print(blue("Information"))

red(), green() и остальные функции НЕ вызывают print() самостоятельно. Они возвращают ANSI-цветную строку, которую можно передавать в print(), input(), stars() и другие функции.

Пример:

message = red("Error")
print(message)

Все 12 цветов

Function Color
red() Red
green() Green
blue() Blue
yellow() Yellow
orange() Orange
purple() Purple
pink() Pink
cyan() Cyan
lime() Lime
gray() Gray
white() White
gold() Gold

Полный импорт:

from mukimov.color import (
    red,
    green,
    blue,
    yellow,
    orange,
    purple,
    pink,
    cyan,
    lime,
    gray,
    white,
    gold,
)

Colors + input()

from mukimov.color import red, green

username = input(red("Username: "))
password = input(green("Password: "))

Цвет применяется к prompt терминала: текст приглашения отображается цветным, а введённое пользователем значение остаётся обычным.

Colors + stars()

Один из главных примеров README:

from mukimov import stars
from mukimov.color import cyan, green, red

print(cyan("=== LOGIN ==="))

username = input(green("Username: "))
password = stars(green("Password: "))

if username == "Mukimov":
    print(green("Login successful!"))
else:
    print(red("Invalid username!"))

stars() продолжает скрывать ввод пароля (показывает mask-символы вместо реальных нажатий), а цветовая функция отвечает только за цвет prompt.

Validation

Функции цветов принимают только str.

Например:

red(123)

результат:

TypeError: red() expected str, got int

Также запрещены пустые строки и строки только из whitespace:

red("")
red("   ")
red("\t")
red("\n")

Ожидается:

ValueError: red() text cannot be empty

При этом:

red("Username: ")

полностью корректно.

Исходный текст сохраняется без .strip() — пробелы внутри нормального текста разрешены и не изменяются.

ANSI / RESET

Цвет реализован через ANSI escape sequences: каждая функция оборачивает текст в код своего цвета и автоматически добавляет RESET (\x1b[0m) в конец строки, поэтому цвет не распространяется на последующий вывод.

Например:

print(red("Error"))
print("Normal text")

Normal text отображается обычным цветом терминала.

Поддержка:

  • Windows Terminal
  • PowerShell
  • Linux terminals

Для цветов не требуются сторонние зависимости — только чистый Python.

Errors

mukimov raises clear, descriptive errors in Russian. Each message tells you which parameter is wrong, what value was passed, why it is wrong, what was expected, and shows a correct example.

Wrong usage:

stars("Password: ", "//")

Error:

ValueError: Параметр mask='//' содержит 2 символа. Допускается только 1 символ.
Пример: stars("Password: ", "*")

More examples (real messages from the library):

stars("Password: ", "")
ValueError: Параметр mask='' пустой. Укажите ровно 1 символ для маскировки.
Пример: stars("Password: ", "*")
stars("Password: ", 123)
TypeError: Параметр mask должен быть строкой (str), но получен int: 123.
Пример: stars("Password: ", "*")
stars(123)
TypeError: Параметр prompt должен быть строкой (str), но получен int: 123.
Пример: stars("Password: ")

Platform Support

Only systems actually supported by the current code are listed:

OS Backend
Windows msvcrt
Linux termios / tty
macOS termios / tty

The library uses only the Python standard library — no third-party dependencies. When standard input is not a TTY (pipes, IDE consoles, CI), it safely falls back to getpass with no echo.

Extra behavior worth knowing:

  • Backspace deletes the last mask character and the last symbol.
  • Enter finishes input.
  • Ctrl+C raises KeyboardInterrupt, Ctrl+D on empty input raises EOFError.

Why mukimov?

The goal of mukimov is a simple, short API for masked terminal input.

mukimov:

from mukimov import stars

password = stars("Password: ", "•")

And the standard-library alternative, where your Python version supports echo_char:

from getpass import getpass

password = getpass("Password: ", echo_char="•")

If you like the classic getpass, keep using it — mukimov is just a compact option when you want per-character masking with a tiny API.

Security 🔒

mukimov hides the password only visually, while it is being typed.

It does NOT:

  • hash the password
  • encrypt the password
  • store the password securely by itself
  • protect the process from malware
  • protect the contents of the process memory

After input, the function returns the real password as a regular Python string. To store passwords, developers must separately use a reliable password-hashing solution.

Also, error messages and logs of this library never include the typed password — only configuration values (prompt, mask) may appear in validation errors.

API

stars(prompt="Password: ", mask="*")

Parameters:

  • prompt: str — text displayed before input.
  • mask: str — exactly one character shown instead of each typed symbol.

Returns:

  • str — the real text the user typed.

Exceptions:

  • TypeError — prompt or mask is not a string.
  • ValueError — mask is empty or longer than one character.

Color API

red(text: str) -> str
green(text: str) -> str
blue(text: str) -> str
yellow(text: str) -> str
orange(text: str) -> str
purple(text: str) -> str
pink(text: str) -> str
cyan(text: str) -> str
lime(text: str) -> str
gray(text: str) -> str
white(text: str) -> str
gold(text: str) -> str

Each color function takes a string and returns it wrapped in its ANSI color code with RESET applied at the end. Raises TypeError for non-string input and ValueError for empty/whitespace-only strings.

Project

Release files for mukimov 0.1.5

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

Source distribution (sdist)

Source distribution for mukimov 0.1.5
File Size Uploaded
mukimov-0.1.5.tar.gz 17.2 kB Details

Built distribution (wheel)

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

Total release size: 27.9 kB

Release files / mukimov-0.1.5.tar.gz

Download URL mukimov-0.1.5.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
021900ce05465fcd58f7be64599d6f12d980533e1ea2da0579b1511005d3aa42
BLAKE2b-256 checksum
How to use checksums
5d14c40d1accad278cc17ae577c7f6e5e85c6c28f0fb9fc20f6ccdb2039a629a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / mukimov-0.1.5-py3-none-any.whl

Download URL mukimov-0.1.5-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3884dfb7c7b4f095c0a7c7b51e05eaf23e8e2b79599cfc4cd888194c7eb50d6b
BLAKE2b-256 checksum
How to use checksums
a3a8e24560806ceeea5ba02ed414f729f404881ea113344839bd257e9567bde3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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