Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreyrusyaev/simpleauthenticator
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.
https://github.com/andreyrusyaev/simpleauthenticator
google-authenticator hotp hotp-generator microsoft-authenticator one-time-password otp otp-generator rfc4226 rfc6238 totp totp-generator
Last synced: 6 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/andreyrusyaev/simpleauthenticator
- Owner: AndreyRusyaev
- License: mit
- Created: 2023-01-08T14:06:38.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-18T16:03:12.000Z (27 days ago)
- Last Synced: 2024-10-20T20:44:18.303Z (25 days ago)
- Topics: google-authenticator, hotp, hotp-generator, microsoft-authenticator, one-time-password, otp, otp-generator, rfc4226, rfc6238, totp, totp-generator
- Language: C#
- Homepage:
- Size: 21.5 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simpleauthenticator
Cross-platform C#/.Net implementation to generate one time passwords for open authentication defined by standard RFC's:
* [HOTP: An HMAC-Based One-Time Password Algorithm](https://www.rfc-editor.org/rfc/rfc4226),
* [TOTP: Time-Based One-Time Password Algorithm](https://www.rfc-editor.org/rfc/rfc6238)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:
``` shell
git clone https://github.com/AndreyRusyaev/simpleauthenticator
cd simpleauthenticator
dotnet run totp --secretkey ""
```Output:
```shell
Token: 123456.
```# Prerequisites
.Net 6.0 or higher.[Install .NET on Windows, Linux, and macOS](https://learn.microsoft.com/en-us/dotnet/core/install/)
### Windows
``` shell
winget install Microsoft.DotNet.SDK.8
```### MacOS
``` shell
brew install dotnet
```### Ubuntu
``` shell
# 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 update
sudo apt-get install -y dotnet-sdk-8.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 informationCommands:
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 Base32 encoded secret key (whitespaces allowed). Example:
'A5YS 2UP6 K4UF 46GD'.
-s64, --secretkey-base64 Base64 encoded secret key (whitespaces allowed). Example:
'B3Et Uf5X KF54 ww=='.
--token-length Token length. Default: 6.hotp Command Options:
-s, --secretkey, --secretkey-base32 Base32 encoded secret key (whitespaces allowed). Example:
'A5YS 2UP6 K4UF 46GD'.
-s64, --secretkey-base64 Base64 encoded secret key (whitespaces allowed). Example:
'B3Et Uf5X KF54 ww=='.
-c, --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. Default: 6.
```# Examples
## TOTP: Generate time-based one time password
``` shell
git clone https://github.com/AndreyRusyaev/simpleauthenticator
cd simpleauthenticator
dotnet run totp --secretkey "A5YS 2UP6 K4UF 46GD"
```OR
``` shell
git clone https://github.com/AndreyRusyaev/simpleauthenticator
cd simpleauthenticator
dotnet run totp --secretkey-base64 "B3Et Uf5X KF54 ww=="
```Output:
``` shell
Token: 316788.
```## HOTP: Generate HMAC-based one time password
``` shell
git clone https://github.com/AndreyRusyaev/simpleauthenticator
cd simpleauthenticator
dotnet run hotp --counter 12345 --secretkey "A5YS 2UP6 K4UF 46GD"
```OR
``` shell
git clone https://github.com/AndreyRusyaev/simpleauthenticator
cd simpleauthenticator
dotnet run hotp --counter 12345 --secretkey-base64 "B3Et Uf5X KF54 ww=="
```Output:
``` shell
Token: 316788.
```