HYBRID ENCODING SYSTEM USING BIGINT AND TOTP FOR TEXTUAL DATA AND IMAGE PROTECTION
Authors/Creators
Description
π§ ENCODER-AND-DECODER
The BigInt + TOTP Encoder and Decoder is a web-based tool built in HTML and JavaScript that allows users to securely encode and decode text and images using encryption based on large integers (BigInt) and time-based authentication (TOTP – Time-Based One-Time Password).
π§© General Functioning
The system has four main sections:
π€ Text Encoder
Transforms plain text into an encrypted number (mixedBigInt in hexadecimal) and generates a secret key (TOTP Secret in base32).
π Text Decoder
Reconstructs the original text using the mixedBigInt, the TOTP Secret, and a one-time code generated by an authenticator app (for example, Google Authenticator).
πΌοΈ Image Encoder
Compresses and encodes images automatically into approximately 30 pages (~90KB) of hexadecimal text.
It supports multiple formats: JPG, PNG, GIF, BMP, WEBP, SVG, TIFF, AVIF, and others.
All images are converted to JPEG during the compression process.
π§Ύ Image Decoder
Reconstructs the original image using the mixedBigInt, the TOTP Secret, and a valid TOTP code.
π Main Technical Steps
-
The text or image (as base64) is converted into bytes, and then into a very large integer (BigInt).
-
A random secret (20 bytes) is generated and converted into Base32, forming the TOTP Secret.
-
From this secret, the system derives a unique prime number used to mix with the original value — producing the mixedBigInt (encoded data).
-
For images: automatic compression resizes the image to a maximum of 1200px and adjusts JPEG quality dynamically to reach ~90KB, ensuring about 30 pages of hexadecimal text.
-
To decode, the user must provide the
mixedBigInt, theTOTP Secret, and a valid TOTP code (which refreshes every 30 seconds). -
The system validates the TOTP code and, if correct, divides the
mixedBigIntby the derived prime to recover the original text or image.
βοΈ Main Technologies Used
-
Modern JavaScript (ES6+)
-
Web Crypto API — used for generating HMAC-SHA1 and SHA-256
-
BigInt — used for operations with extremely large numbers
-
Base32 — ensures compatibility with authenticator apps
-
Canvas API — handles image compression and format conversion
πΌοΈ Image Compression Details
| Feature | Description |
|---|---|
| Supported formats | JPG, PNG, GIF, BMP, WEBP, SVG, TIFF, AVIF, and others |
| Automatic resizing | Maximum size: 1200px (maintains aspect ratio) |
| Dynamic quality | JPEG quality automatically adjusted to target ~90KB |
| Output format | All images converted to JPEG |
| Result | About 30 pages of hexadecimal text instead of 130+ pages for a 321KB image |
π‘ Purpose
The goal of this project is to protect textual data and images without transmitting or storing the original secret.
It combines mathematical encoding and two-factor authentication (2FA), ensuring that only users who possess both the TOTP Secret and a valid authentication code can decrypt the content.
π Encode text and image, and then decode using the website below:
π https://k10.netlify.app/projetos/text&image
π https://github.com/andradepsa/ENCODER-AND-DECODER
π§© STEPS
-
Enter the mixedBigInt (hex) value into the decoder on the website.
-
Enter the TOTP Secret (base32) and input the required characters.
-
Register the TOTP Secret (base32) in your Authenticator app to generate verification codes.
β Additions and Enhancements
-
Added image encoding to the system.
-
Included details about supported image formats (JPG, PNG, GIF, BMP, WEBP, SVG, TIFF, AVIF).
-
Explained automatic compression to around 30 pages of hexadecimal data.
-
Noted that all images are converted to JPEG during compression.
-
Added technical information about the Canvas API.
-
Compared file size reduction (321KB → 90KB).
Files
HYBRID ENCODING SYSTEM USING BIGINT AND TOTP FOR TEXTUAL DATA PROTECTION.md
Files
(18.0 kB)
| Name | Size | Download all |
|---|---|---|
|
md5:7c82649dd9bb03a921a565766cbff132
|
18.0 kB | Preview Download |