The author's main SQL code seems to be in this file: <a href="https://github.com/pyramation/totp/blob/master/packages/totp/deploy/schemas/totp/procedures/generate_totp.sql" rel="nofollow">https://github.com/pyramation/totp/blob/master/packages/totp...</a><p>For comparison, these are my relatively short TOTP implementations in {TypeScript, Python, Java, Rust, C++}: <a href="https://www.nayuki.io/page/time-based-one-time-password-tools" rel="nofollow">https://www.nayuki.io/page/time-based-one-time-password-tool...</a> . I even have a 6-line Python function.