7 ms·
It can be done as a bash one liner, so yeah, definitely doable in minimal lines of Python code. More than 50% of this file is “overhead” even.
by jsjohnst 4y ago
It can be done as a bash one liner, so yeah, definitely doable in minimal lines of Python code. More than 50% of this file is “overhead” even.
- tyingq 4y agoI don't see any fluff myself. Where's the overhead?
- tantalor 4y agoWrapper functions, imports, input handling, etc.
- jsjohnst 4y agoIt’s not “fluff”, it’s overhead. The real work there is done in about 4 lines (which could be compacted to two and still be somewhat readable). The rest as someone else already said, imports, helper functions (there’s no technical need for totp to just be a wrapper around hotp unless you want to expose hotp or be illustrative), function overhead, etc. That said, TOTP shouldn’t be treated as code golf, especially in production code. The point is the protocol is trivially simple to implement not that it’s X lines in Y language.
- tyingq 4y agoAh, okay. It doesn't appear overly golfed to me. It felt like the point of publishing it was probably similar to what you're saying. That the TOTP algorithm isn't terribly complicated.
- masklinn 4y agoIt's not golfed at all, it's more or less where you get when you implement TOTP by hand from the RFCs. Except for the final reduction, which in the RFC is implemented via a mod, and the base32 decoding, which is not part of either HOTP or TOTP RFCs, but is instead part of the ad hoc "key uri" format. Which is a funny spec because it was defined for Google Authenticator yet AFAIK GA uses none of the parametrisation so that's only useful if you specifically want to exclude GA users.
- martinky24 4y agoIt can be done with a python 1-liner by that logic! `mintotp.totp('ZYTYYE5FOAGW5ML7LRWUL4WTZLNJAMZS')`
- jsjohnst 4y agoI meant specifically chaining generic commands, not a purpose built tool.
- maratc 4y agoCan you paste your bash one-liner here?
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- gabrielbarros 4y agooathtool --base32 --totp VHR2WYCQPNXIFB2SPLIAE2AZHQ
- remram 4y agoWhich part of this involves bash? This is an "oathtool one-liner" if anything.
- 22c 4y agoThe other "bash" one-liner references a bunch of tools that are not part of bash or even a POSIX environment. FWIW I would rather use oathtool than the other monstrosity.
- jsjohnst 4y ago> The other "bash" one-liner references a bunch of tools that are not part of bash or even a POSIX environment. You do understand that there is a commonly accepted definition of a bash one-liner and that the one I shared fits that definition spot on, right? Further, there is a bunch of very Bash specific code in it that doesn't work in most other Posix compliant shells, so your scare quotes feel even more like a failed trolling attempt. > FWIW I would rather use oathtool than the other monstrosity. So would any sane person. The point wasn't what you should use, it was what is possible, which if you had read comments up the thread chain and tried to understand the context rather than making it a pissing contest about which tool is better when that wasn't even the question at hand.