4 ms·
Yeah, I have implemented it in PHP and Lua as well, cannot check the LOC right now, but it is around ~30 as well, if not less, at least in PHP.
by johnisgood 2y ago
Yeah, I have implemented it in PHP and Lua as well, cannot check the LOC right now, but it is around ~30 as well, if not less, at least in PHP.
- deltaknight 2y agoIt’s definitely a fairly trivial implementation, here’s one of a few dozen lines of (not very clean) Swift: https://github.com/JustAman62/ovault/blob/7ee38b7e5c2666cd34994343d8dd9d322c372f6f/Models/Otp%2BOTP.swift#L30 https://github.com/JustAman62/ovault/blob/7ee38b7e5c2666cd34... The simplicity of the implementation makes a test suite even more valuable, as it’s really quite hard to figure out if your implementation is correct.
- edent 2y agoAs part of writing the test suite, I also wrote an implementation in JavaScript. It uses the Web Crypto API rather than external libraries. https://shkspr.mobi/blog/2025/03/using-the-web-crypto-api-to-generate-totp-codes-in-javascript-without-3rd-party-libraries/ https://shkspr.mobi/blog/2025/03/using-the-web-crypto-api-to...