ALogin Documentation
Lightweight Python authentication library with SHA-256 hashing and a zero-dependency JSON user store.
Overview
ALogin provides simple, secure account creation and login for Python CLI tools and scripts — no external dependencies required. It's built for developers who want to add basic authentication to small to medium-sized projects without pulling in a full auth framework.
pip install alogin
Features
- Account creation — register users with email validation and duplicate protection.
- Login authentication — authenticate accounts with hashed password comparison.
- SHA-256 hashing — passwords are never stored or transmitted in plain text.
- JSON user database — flat-file storage with zero external dependencies.
Quickest way to start
pip install alogin
from alogin import create_account, login_account create_account() login_account()
Installation
Install ALogin from PyPI — no external dependencies needed.
Requirements
Python 3.6 or higher. ALogin only uses modules from the standard library (hashlib, json, getpass).
Install via pip
pip install alogin
Install from source
git clone https://github.com/ADEEP13/alogin.git cd alogin pip install -e .
Verify installation
python -c "import alogin; print('ALogin installed successfully')"
python -m venv venv && source venv/bin/activate before installing.
Quick Start
Create an account and authenticate a user in under ten lines of Python.
Step 1 — create an account
Call create_account(). It prompts for an email and password, hashes the password, and writes the record to users.json.
from alogin import create_account create_account() # → Enter email: [email protected] # → Enter password: ******** # → Account created!
Step 2 — log in
Call login_account(). Returns True on success, False otherwise.
from alogin import login_account
result = login_account()
if result:
print("Welcome back!")
Full example
from alogin import create_account, login_account
create_account()
authenticated = login_account()
if authenticated:
print("Access granted.")
else:
print("Access denied.")
API Reference
Full reference for all public functions exported by ALogin.
create_account() → None
Interactively prompts for a new user's email and password. Hashes the password with SHA-256 and writes the record to users.json. Raises a ValueError if the email is already registered.
| Parameter | Description |
|---|---|
| — | No parameters — prompts via stdin. |
from alogin import create_account create_account() # returns None
login_account() → bool
Prompts for email and password. Hashes the input and compares it against the stored SHA-256 hash.
| Returns | Type | Description |
|---|---|---|
| result | bool | True on successful authentication, False on failure. |
result = login_account() # returns True or False
Security
How ALogin protects user credentials and what to be aware of in production.
Password hashing
All passwords are hashed using SHA-256 via Python's hashlib module before being written to disk. Plain-text passwords are never stored or logged.
Duplicate email protection
Each email address can only be registered once. Attempting to create a second account raises a ValueError before any write occurs.
JSON storage
User records are stored in a local users.json file. Ensure this file is excluded from version control.
users.json
Known limitations
SHA-256 without salting is vulnerable to rainbow table attacks. For stronger security, use bcrypt or argon2 in your own implementation.
Changelog
Full version history for ALogin.
v0.1.2 — Latest
- Fixed bugs in
__init__.py
v0.1.1 — Improvements
- Exported both
create_account()andlogin_account()from the package - Cleaner import style — use
from alogin import create_account, login_account
v0.1.0 — Initial release
- JSON-based user database
- Login authentication system
- Password hashing
- Duplicate email protection