News for hackers. Stuff that matters.
Re:Tiny Toy TOTP Generator in 18 Lines of Python by pushpop on Sunday August 11, 2019 @08:53AM (#20667957)
I get your point but equally the point of programming languages is to abstract away the harder stuff. The question is just how much abstraction developers want between the code and the execution.

I mean, you could make the same claim about one written in C because it doesn’t include stdio.h. So where do you draw the line? Assembly?

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.
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.