Re:Tiny Toy TOTP Generator in 18 Lines of Python
by xendo on Sunday August 11, 2019 @09:16AM
(#20668034)
My point is that saying that something is written in 18 lines of code when actually all the heavy lifting is done by the libraries is misleading. That doesn’t mean I don’t appreciate Python’s expressiveness and rich standard library.
[ Parent
| on HN ]
Re:Tiny Toy TOTP Generator in 18 Lines of Python
by icebraining on Sunday August 11, 2019 @10:36AM
(#20668346)
Yeah, but that comment can be made about literally every software in existence. Even core language keywords are doing a lot of heavy lifting in the interpreter.
In Python, the stdlib is effectively part of the language, so as long as they're not installing third-party libs, I don't see how it can be misleading.
Re:Tiny Toy TOTP Generator in 18 Lines of Python
by anamexis on Sunday August 11, 2019 @11:17AM
(#20668518)
I think you both raise valid points.
This was an interesting thing to look at to see get a quick idea of how TOTP works.
On the flip side, though, if this we had this hypothetical implementation:
import totp
if __name__ == '__main__':
totp.generate()
Well, we probably wouldn't be here discussing it.
Re:Tiny Toy TOTP Generator in 18 Lines of Python
by PeterisP on Sunday August 11, 2019 @11:58AM
(#20668695)
Well, the key part essentially is just like that, it's the single line
mac = hmac.new(secret_bytes, counter_bytes, digest).digest()
and everything else is just converting data to/from the proper format for this function.
Re:Tiny Toy TOTP Generator in 18 Lines of Python
by anamexis on Sunday August 11, 2019 @01:45PM
(#20669354)
Well sure, but given that TOTP is itself just formatted HMAC, that "everything else" of formatting is the essence of TOTP.
Otherwise you probably wouldn't say you're implementing TOTP, you'd say you're implementing HMAC.