jchambers / java-otp

A one-time password (HOTP/TOTP) library for Java
MIT License
455 stars 122 forks source link

Switch back to `ByteBuffer` when generating one-time passwords #23

Closed jchambers closed 3 years ago

jchambers commented 3 years ago

Previously, I switched from using ByteBuffer to byte[] in the interest of avoiding an allocation on every call to generateOneTimePassword. It turns out those were two orthogonal ideas, though, and we can keep the ByteBuffer and still avoid repeated allocations.

Switching back to a ByteBuffer makes things a lot more readable and ~actually gives us a very modest throughput boost, too~ has no statistically-significant effect on throughput.