Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/remjey/luaotp
A simple implementation of OATH-HOTP and OATH-TOTP written for Lua
https://github.com/remjey/luaotp
otp
Last synced: about 2 months ago
JSON representation
A simple implementation of OATH-HOTP and OATH-TOTP written for Lua
- Host: GitHub
- URL: https://github.com/remjey/luaotp
- Owner: remjey
- License: mit
- Created: 2015-08-11T14:46:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-07-22T22:13:16.000Z (over 6 years ago)
- Last Synced: 2024-08-01T03:30:08.243Z (4 months ago)
- Topics: otp
- Language: Lua
- Size: 21.5 KB
- Stars: 26
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- stars - remjey/luaotp - HOTP and OATH-TOTP written for Lua (HarmonyOS / Windows Manager)
README
# luaotp
A simple implementation of OATH-HOTP and OATH-TOTP. It is distributed
under the terms of the MIT licence.## Description
This is a simple OATH-HOTP and OATH-TOTP implementation in pure lua
that makes use of LuaCrypto for its hashing needs. It can be used as
a generation and verification library and is compatible with the
RFCs 4226 and 6238. It only supports the SHA-1 hashing algorithm
(as specified in the RFCs).It is possible to export and import the keys in a short ASCII format
for easy storing in databases or text files.It is also possible to export a key to a standard URL format that
will work with ``otpauth://`` aware clients and can be simply converted
to a QR code to be scanned by mobile clients.## Example
HOTP sample code that creates a shared secret and iterates over asking
and testing codes from the user until it encounters a blank line.The counter is incremented with each successful verification, so one
code can't be used twice.```lua
local otp = require"otp"local hotp = otp.new_hotp()
print"Use this URL to configure your OATH-HOTP client:"
print(hotp:get_url("luaotp sample", "user"))while true do
print"Type in a code:"
local code = io.stdin:read"*l"
if not code or code == "" then break endif hotp:verify(code) then
print"This code is valid!"
else
print"This code is invalid."
end
end
```## Documentation
The documentation can be found in the doc folder.
---
[Jérémy Farnaud](http://jf.almel.fr/)
If you like this project, you can either [Flattr](https://flattr.com/profile/remjey) or donate on [Liberapay](https://liberapay.com/remjey).