• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

? Build & Run Your Own TOTP Generator in Under 5 Minutes — with Amazon Q Developer

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
This is a submission for the

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

: Crushing the Command Line


Context


We all know that Multi-Factor Authentication (MFA) is essential for securing our accounts. But let’s be honest—how many times have you felt frustrated opening your phone, launching the authenticator app, and copying the OTP code every time you're logging in somewhere on your work computer or laptop?

Worse, what if your phone is de*d, lost, or simply not nearby? You’re locked out.

That’s why I built this project: a TOTP (Time-based One-Time Password) generator tool available as both a command-line interface and a lightweight frontend.

It lets you instantly generate TOTP codes from a saved secret—no phone required.

What I Built


I built a TOTP (Time-based One-Time Password) generator tool that runs on both the command line and a simple frontend web interface. This tool solves the problem of securely generating one-time passwords commonly used in 2FA (Two-Factor Authentication) systems.

⚙ CLI tool: Instantly generates TOTP codes from a shared secret via terminal. It supports auto-copying the generated code using the clipboard.

? Frontend demo: A minimal web interface that visualizes the TOTP flow and shows the code updating every 30 seconds.

This tool is lightweight and designed for developers who frequently work with authentication flows, or for testing their 2FA setup during app development.

Demo


?︎ Live page:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



After asking Amazon Q Developer to build the application and generate an initial flow diagram, I took the time to deepen my understanding of how TOTP works. I then created my own visual explanation to solidify and share that understanding (with a demo secret key, so it's just fine like that):

? My custom TOTP flow diagram (made with Excalidraw):

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? Extracting a TOTP Secret Key from a GitHub QR Code
This screenshot shows how I used my CLI tool to scan a QR code (e.g., from GitHub's 2FA setup) and retrieve the base32 secret key.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



When scanning a QR code with my Samsung phone (just once), you can extract the secret key from the QR's value, which typically follows this format: otpauth://[OTP_type]/[issuer]:[user_identity]?secret=[secret_key]&issuer=[issuer]


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



For example, if the value is: otpauth://totp/GitHub:longphanquangminh?secret=ggg&issuer=GitHub => Then the secret_key would be ggg

?️? Matching OTPs on Both CLI and Web UI
To demonstrate accuracy, I used the same TOTP secret in both the CLI and web tool. As shown below, both generated the same OTP codes, just like a real authenticator app would:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Code Repository


? GitHub Repo:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



  • /cli – Node.js terminal utility with clipboard integration.
  • /web – Frontend TOTP display tool with diagram and styling.
How I Used Amazon Q Developer


Amazon Q Developer played a huge role in helping me build and polish this tool quickly. Here’s how I used it:

? Idea to Execution — Powered by Amazon Q

  1. Logged into Amazon Q Developer via q login from my terminal.
  2. Opened Q Chat via q chat to brainstorm implementation details and flow.
  3. Prompted Q: How do I implement a TOTP generator CLI tool in Node.js that auto-copies the result to clipboard? → Q provided sample code using otplib and clipboardy. But in this case, after doing some research, I decided to use otpauth instead of otplib because it's newer and offers more flexible customization of the algorithm and time settings.
  4. Used Q to help draw a simple diagram explaining the TOTP flow (time + secret → HMAC → OTP).
  5. Asked Q to help improve the CLI experience (formatting, error handling, feedback, timer).
  6. Switched to the frontend: I asked Q to style the TOTP web page, make it responsive, and implement the 30-second countdown bar.
  7. Completed both tools in a much shorter time than building from scratch.

? With the help of Amazon Q, I built both the CLI tool and the frontend app in literally under 5 minutes.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? Tips for Using Amazon Q Developer

  1. Be clear and specific in your prompts.
  2. Ask for architecture and visual explanations too—not just code.
  3. Iterate with Q! Ask it to improve or adapt to your stack.
Disclaimer


This tool was built for educational purposes and as a submission for the Amazon Q Developer “Quack The Code” Challenge. Please use it responsibly. Personally, I believe if you're using a work or company-issued computer — especially as a software engineer — it's acceptable to store TOTP secrets locally for convenience, as long as your device is secured. Relying solely on a phone with many apps also carries potential risks.

?‍? Built by

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

and Amazon Q Developer


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу