Skip to content

This is a Hexa Decimal number generator without replication for 2 factor authentication.

Notifications You must be signed in to change notification settings

PraAnj/hexadecimal-2fa-code-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hexa Decimal Code Generator for 2FA

Build Status PEP8

This repo can be used to generate 8 digit hexadecimal numbers for 2fa. Following rules are applied,

  1. Every time you run the program, it should emit one 8-digit hexadecimal code;
  2. It should emit every possible code before repeating;
  3. It should not print "odd-looking" codes such as 0xAAAAAAAA or 0x01234567 or any commonly used words, phrases, or hexspeak such as 0xDEADBEEF;

Design

In order to avoid using duplicate codes, already used codes should be persisted on the disk. Hexa nunmbers dictionary would be more than 4B numbers (4,294,967,296), hence storing 4B hexa numbers with 8 digits would take more than 16GB disk space as each code requires 4 bytes. Hence only a boolean flag, marking whether the positional code is used or not, is persisted on disk which only takes about half a GigaByte (536 MB). These numbers are stored in a hierarchycal folder system for faster retrieval by reducing the search scope by a factor of 16 at each iteration as shown in figure below. Once all the codes in a particular path are used, those paths are deleted recursively from the tree to avoid traversing non existance paths. The folder hierarchy will be re-created once all the codes are used, which happens eventually after deletion of ROOT folder.

How to use

  1. Clone the repository

  2. Install the dependencies via requirements.txt

     pip install -r requirements.txt
    
  3. Run the code generator

     cd src
     ./code_generator.py
     pytest pytester.py # for testing
    

TODO

  1. PEP8 style checker, github actions (Refer:- https://github.com/marketplace/actions/pycodestyle)
  2. Update pytests to catch edge cases
  3. Update requirements.txt for easy installations.
  4. Calculate perf values for first folder creation, and random number generation
  5. Write a crawler utility to retrieve remaining magic hexa numbers (Ex:-Beautifilsoup)
  6. Implement a way to encrypt the folder hierarchy and files

About

This is a Hexa Decimal number generator without replication for 2 factor authentication.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages