Comments (2)
It's hand rolled to match Google Authenticator's ignoring padding. See #29 and https://code.google.com/p/google-authenticator/source/browse/src/com/google/android/apps/authenticator/Base32String.java?repo=android#101
Most sites stick to using a random string of base32 characters as the secret, usually 16 bytes long (Google) or 24(Dropbox).
Feel free to reopen this if you feel there's a better solution.
from rotp.
Oh, and TOTP.new expects to be passed a string of Base32 characters. Your example above would be double encoding the secret
Base32.encode("dntqoaxas7rvtfuf") #=> "MRXHI4LPMF4GC4ZXOJ3HIZTVMY======"
ROTP::TOTP.new("dntqoaxas7rvtfuf")
would be the preferred instantiation in this case and would match the output of most OTP mobile apps sharing this secret.
Hope that helps.
from rotp.
Related Issues (20)
- TOTP wrong code HOT 2
- Warning after upgrading to Ruby version 2.7.2 HOT 2
- Would you be willing to add a 6.2 tag? HOT 1
- TOTP verification passes/fails randomly HOT 4
- Undefined method verify_with_drift HOT 2
- TOTP deemed invalid within the `interval` HOT 2
- CVE Alert due to bundling jQuery 1.4.2 HOT 3
- Cannot verify OTP in a separate request HOT 2
- Ruby 2.3 needs older Bundler to work
- rotp and mathn HOT 1
- Expired code if internal was set more than 1 minute HOT 1
- No option to set drift/at in HOTP HOT 1
- Feature Request SHA256 based TOTP HOT 4
- wrong code - oauthtool vs mdp/rotp HOT 3
- Wrong number of arguments error HOT 1
- Missing tag for rotp v5.0.0 HOT 1
- Please explain what happened to #random_base32 HOT 1
- How to save a secret code to a user HOT 1
- spaces double-encode in issuer parameter field
- Proposal: create backup code function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rotp.