Replace the equal signs in base32 string
This commit is contained in:
parent
3c9391bc36
commit
1662edf203
@ -45,8 +45,11 @@ var key = 'secret key for the user';
|
|||||||
// encoded will be the secret key, base32 encoded
|
// encoded will be the secret key, base32 encoded
|
||||||
var encoded = base32.encode(key);
|
var encoded = base32.encode(key);
|
||||||
|
|
||||||
|
// Google authenticator doesn't like equal signs
|
||||||
|
var encodedForGoogle = encoded.toString().replace(/=/g,'');
|
||||||
|
|
||||||
// to create a URI for a qr code (change totp to hotp is using hotp)
|
// to create a URI for a qr code (change totp to hotp is using hotp)
|
||||||
var uri = 'otpauth://totp/somelabel?secret=' + encoded;
|
var uri = 'otpauth://totp/somelabel?secret=' + encodedForGoogle;
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: If your label has spaces or other invalid uri characters you will need to encode it accordingly using `encodeURIComponent` More details about the uri key format can be found on the [google auth wiki](https://code.google.com/p/google-authenticator/wiki/KeyUriFormat)
|
Note: If your label has spaces or other invalid uri characters you will need to encode it accordingly using `encodeURIComponent` More details about the uri key format can be found on the [google auth wiki](https://code.google.com/p/google-authenticator/wiki/KeyUriFormat)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user