Permalink
Browse files

Thanks to Russell Sayers other length of keys also work (quickfix)

  • Loading branch information...
1 parent 5a9fa3f commit 5a3b1593e31027375a0702bcb1da99f08040a00d @gbraad committed Sep 11, 2012
Showing with 22 additions and 27 deletions.
  1. +5 −9 code.js
  2. +6 −6 index.html
  3. +11 −12 sha.js
View
@@ -30,7 +30,7 @@ StorageService.isSupported = function() {
}
-// Originally based on the JavaScript implementation as provided by Tin Isles:
+// Originally based on the JavaScript implementation as provided by Russell Sayers on his Tin Isles blog:
// http://blog.tinisles.com/2011/10/google-authenticator-one-time-password-algorithm-in-javascript/
var KeyUtilities = {}
@@ -51,16 +51,12 @@ KeyUtilities.base32tohex = function(base32) {
var val = base32chars.indexOf(base32.charAt(i).toUpperCase());
bits += KeyUtilities.leftpad(val.toString(2), 5, '0');
}
-
- // leftpad bits with 0 until length is a multiple of 4
- while (bits.length % 4 != 0) {
- bits = "0" + bits;
- }
-
- for (var i = bits.length - 4; i >= 0; i = i - 4) {
+
+ for (var i = 0; i + 4 <= bits.length; i += 4) {
var chunk = bits.substr(i, 4);
- hex = parseInt(chunk, 2).toString(16) + hex;
+ hex = hex + parseInt(chunk, 2).toString(16);
}
+
return hex;
}
View
@@ -7,6 +7,7 @@
<meta name="HandheldFriendly" content="True">
<meta http-equiv="cleartype" content="on">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
+ <!-- purposely at the top -->
<script src="jquery-1.7.2.min.js"></script>
<script src="init.js"></script>
<script src="jquery.mobile-1.1.0.min.js"></script>
@@ -22,16 +23,14 @@
<div data-role="header">
<h1>GAuth Authenticator</h1>
- <a href="#settings" data-role="button" data-rel="dialog">Settings</a>
- <a href="#about" data-role="button" data-rel="dialog">About</a>
+ <a href="#settings" data-role="button" data-rel="dialog" data-icon="plus" data-iconpos="notext">Settings</a>
+ <a href="#about" data-role="button" data-rel="dialog" data-icon="info" data-iconpos="notext">About</a>
</div>
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="a" data-split-theme="b" data-split-icon="delete" id="accounts">
<li id="accountsHeader" data-role="list-divider">One-time passwords<span class="ui-li-count" id='updatingIn'>..</span></li>
- </ul>
-
-
+ </ul>
</div>
<div data-role="footer">
@@ -65,13 +64,14 @@
<h1>About</h1>
</div>
<div data-role="content">
- <p>A simple application for use with Google Authenticator writtin in HTML using jQuery Mobile, jsSHA and LocalStorage.</p>
+ <p>A simple application for use with Google Authenticator written in HTML using jQuery Mobile (and PhoneGap), jsSHA and LocalStorage.</p>
<p><ul>
<li>Online<br/><a href="http://gauth.apps.gbraad.nl/">http://gauth.apps.gbraad.nl/</a></li>
<li>Application<br/><a href="https://build.phonegap.com/apps/135419/">for Android</a></li>
<li>Extension<br/><a href="https://chrome.google.com/webstore/detail/ilgcnhelpchnceeipipijaljkblbcobl?utm_source=chrome-ntp-icon">for Chrome</a></li>
<li>Webapp<br/><a href="https://marketplace.mozilla.org/app/gauth-authenticator/">Mozilla Marketplace</a></li>
<li>Source code<br/><a href="http://github.com/gbraad/html5-google-authenticator">http://github.com/gbraad/html5-google-authenticator</a></li>
+ <li>Thanks to Russell Sayers<br/><a href="http://blog.tinisles.com/2011/10/google-authenticator-one-time-password-algorithm-in-javascript/">TOTP Algorithm</a></li>
</ul></p>
<p>For more details or if you have suggestions, please do not hesitate to contact me at <a href="mailto:me@gbraad.nl?subject=gauth+authenticator">me@gbraad.nl</a>.<br/><br/>
<a href="https://flattr.com/thing/717982/GAuth-Authenticator" target="_blank"><img src="images/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" /></a>
View
23 sha.js 100644 → 100755

0 comments on commit 5a3b159

Please sign in to comment.