Code Monkey home page Code Monkey logo

andreyrusyaev / simpleauthenticator Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 17 KB

Cross-platform console C#/.Net implementation to generate one time passwords (TOTP/HOTP) for open authentication defined by standard RFC's (4226, 6238). Compatible with Google/Microsoft Authenticator apps.

License: MIT License

C# 100.00%
hotp one-time-password otp otp-generator rfc4226 rfc6238 google-authenticator hotp-generator microsoft-authenticator totp

simpleauthenticator's Introduction

simpleauthenticator

Cross-platform C#/.Net implementation to generate one time passwords for open authentication defined by standard RFC's:

Compatible with Google/Microsoft Authenticator and other authenticators that supports corresponding RFC's.

How to run it

Ensure that .Net 6 or later is installed

dotnet --version

Clone repository and run totp or hotp command:

git clone https://github.com/AndreyRusyaev/simpleauthenticator
cd simpleauthenticator
dotnet run totp --secretkey "<your base32 encoded secret key>"

Output:

Token: 123456.

Prerequisites

.Net 6.0 or higher.

Install .NET on Windows, Linux, and macOS

Windows

winget install Microsoft.DotNet.SDK.7

MacOS

brew install dotnet

Ubuntu

# Add Microsoft package manager feed
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

# installation
sudo apt-get install -y dotnet-sdk-7.0

Usage

Description:
  Generates one time passwords (HOTP and TOTP tokens).

Usage:
  simpleauthenticator [command] [options]

Options:
  --version       Show version information
  -?, -h, --help  Show help and usage information

Commands:
  totp  Generates time based one time password (TOTP token, RFC 6238).
  hotp  Generates hmac based one time password (HOTP token, RFC 4226).

totp Command Options:
  -s, --secretkey, --secretkey-base32 <secretkey-base32>  Base32 encoded secret key (whitespaces allowed). Example:
                                                          'A5YS 2UP6 K4UF 46GD'.
  -s64, --secretkey-base64 <secretkey-base64>             Base64 encoded secret key (whitespaces allowed). Example:
                                                          'B3Et Uf5X KF54 ww=='.
  --token-length <token-length>                           Token length. Default: 6.

hotp Command Options:
  -s, --secretkey, --secretkey-base32 <secretkey-base32>  Base32 encoded secret key (whitespaces allowed). Example:
                                                          'A5YS 2UP6 K4UF 46GD'.
  -s64, --secretkey-base64 <secretkey-base64>             Base64 encoded secret key (whitespaces allowed). Example:
                                                          'B3Et Uf5X KF54 ww=='.
  -c, --counter <counter> (REQUIRED)                      8-byte counter value, the moving factor.  This counter
                                                          MUST be synchronized between the HOTP generator (client)
                                                          and the HOTP validator (server).
  --token-length <token-length>                           Token length. Default: 6.

Examples

TOTP: Generate time-based one time password

git clone https://github.com/AndreyRusyaev/simpleauthenticator
cd simpleauthenticator
dotnet run totp --secretkey "A5YS 2UP6 K4UF 46GD"

OR

git clone https://github.com/AndreyRusyaev/simpleauthenticator
cd simpleauthenticator
dotnet run totp --secretkey-base64 "B3Et Uf5X KF54 ww=="

Output:

Token: 316788.

HOTP: Generate HMAC-based one time password

git clone https://github.com/AndreyRusyaev/simpleauthenticator
cd simpleauthenticator
dotnet run hotp --counter 12345 --secretkey "A5YS 2UP6 K4UF 46GD"

OR

git clone https://github.com/AndreyRusyaev/simpleauthenticator
cd simpleauthenticator
dotnet run hotp --counter 12345 --secretkey-base64 "B3Et Uf5X KF54 ww=="

Output:

Token: 316788.

simpleauthenticator's People

Contributors

andreyrusyaev avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

simpleauthenticator's Issues

"Tap to approve" function support?

Hi @AndreyRusyaev , thank you for this cool app!

The most often used (and the most annoying) function of Microsoft Authenticator is "Tap to approve". I mean the app screen, where I have to interactively tap "Approve" popup menu, instead of entering the pin code. I think this function is not a part of an RFC, as long as it requires push notifications, rather than just passively entering the pin code. Therefore, I'm not surprised that most of authenticators do not implement it. But if you have to, how would you implement it using your favorite tools?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.