Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6eb270c5df | ||
|
|
517758fdcf | ||
|
|
923c3e185a |
No files matched your search
@@ -0,0 +1,63 @@
|
|||||||
|
# totpin
|
||||||
|
|
||||||
|
A command-line tool to generate TOTP codes (RFC 6238).
|
||||||
|
|
||||||
|
Nothing is stored: totpin asks for a base32 secret, or a full
|
||||||
|
`otpauth://totp/...` URI (which also gives the algorithm, the number of
|
||||||
|
digits and the period), without echoing it. Two codes are then shown, the
|
||||||
|
current one and the next one, each with its countdown. Press any key (or
|
||||||
|
Ctrl-C) to quit.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
totpin [-h] [-v] [--licenses]
|
||||||
|
```
|
||||||
|
|
||||||
|
| Option | Effect |
|
||||||
|
|------------------|-----------------------------------------------------------|
|
||||||
|
| `-h`, `--help` | Show the help, then exit. |
|
||||||
|
| `-v`, `--version`| Show the version, then exit. |
|
||||||
|
| `--licenses` | Show the license of totpin and those of the libraries it uses, then exit. |
|
||||||
|
|
||||||
|
Accepted input:
|
||||||
|
|
||||||
|
- a base32 secret (spaces and `=` are ignored);
|
||||||
|
- an `otpauth://totp/...` URI. The `secret`, `algorithm` (`SHA1`, `SHA256` or
|
||||||
|
`SHA512`), `digits` (6 or 8), `period` and `issuer` parameters are used.
|
||||||
|
Defaults: `SHA1`, 6 digits, 30 seconds.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
Requires OCaml 5.4 or later, [dune](https://dune.build) and opam.
|
||||||
|
|
||||||
|
```
|
||||||
|
opam install . --deps-only
|
||||||
|
dune build
|
||||||
|
```
|
||||||
|
|
||||||
|
The executable is `_build/default/bin/main.exe`. `dune install` installs it
|
||||||
|
as `totpin`.
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
- `bin/`: the executable.
|
||||||
|
- `totpin_base32/`: base32 decoding.
|
||||||
|
- `tools/gen_licenses.ml`: build-time tool that generates the third-party
|
||||||
|
license texts shown by `--licenses`.
|
||||||
|
|
||||||
|
### Third-party licenses
|
||||||
|
|
||||||
|
During the build, `tools/gen_licenses.exe` reads the `(libraries ...)` field
|
||||||
|
of `bin/dune`, finds with `ocamlfind` the libraries linked into the
|
||||||
|
executable (and their dependencies), and reads their opam package, version,
|
||||||
|
declared license and license file from the state of the current opam switch.
|
||||||
|
The result is embedded in the executable.
|
||||||
|
|
||||||
|
This is why the build needs `ocamlfind`, `bos`, and the opam libraries
|
||||||
|
(`opam-core`, `opam-format`, `opam-state`) installed in the switch, and why it
|
||||||
|
must run inside the opam switch that provides the dependencies.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
ISC, Copyright (c) 2026 Matthieu Dubuget. See [LICENSE](LICENSE).
|
||||||
+2
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
(name totpin)
|
(name totpin)
|
||||||
|
|
||||||
(version 1.1)
|
(version 1.5)
|
||||||
|
|
||||||
(generate_opam_files true)
|
(generate_opam_files true)
|
||||||
|
|
||||||
@@ -36,6 +36,7 @@ countdown. Press any key (or Ctrl-C) to quit.")
|
|||||||
digestif
|
digestif
|
||||||
(bos :build)
|
(bos :build)
|
||||||
(ocamlfind :build)
|
(ocamlfind :build)
|
||||||
|
(opam-state :build)
|
||||||
(ocaml-lsp-server :with-dev-setup)
|
(ocaml-lsp-server :with-dev-setup)
|
||||||
(merlin :with-dev-setup)
|
(merlin :with-dev-setup)
|
||||||
(ocamlformat :with-dev-setup)
|
(ocamlformat :with-dev-setup)
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
# This file is generated by dune, edit dune-project instead
|
# This file is generated by dune, edit dune-project instead
|
||||||
opam-version: "2.0"
|
opam-version: "2.0"
|
||||||
version: "1.0"
|
version: "1.5"
|
||||||
synopsis: "A cli tool to generate TOTP codes"
|
synopsis: "A cli tool to generate TOTP codes"
|
||||||
description: """
|
description: """
|
||||||
Nothing is stored: totpin asks for a base32 secret, or a full otpauth://totp/... URI (which also
|
Nothing is stored: totpin asks for a base32 secret, or a full otpauth://totp/... URI (which also
|
||||||
@@ -25,6 +25,7 @@ depends: [
|
|||||||
"digestif"
|
"digestif"
|
||||||
"bos" {build}
|
"bos" {build}
|
||||||
"ocamlfind" {build}
|
"ocamlfind" {build}
|
||||||
|
"opam-state" {build}
|
||||||
"ocaml-lsp-server" {with-dev-setup}
|
"ocaml-lsp-server" {with-dev-setup}
|
||||||
"merlin" {with-dev-setup}
|
"merlin" {with-dev-setup}
|
||||||
"ocamlformat" {with-dev-setup}
|
"ocamlformat" {with-dev-setup}
|
||||||
|
|||||||
Reference in new issue
Block a user