Skip to content

Commit

Permalink
Merge pull request #23 from spacekpe/master
Browse files Browse the repository at this point in the history
UX improvements
  • Loading branch information
kwart committed Apr 22, 2014
2 parents c4d9a3a + b9986db commit 13ffa06
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/java/org/jboss/totp/TOTPMIDlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ public class TOTPMIDlet extends MIDlet implements CommandListener {
private Command cmdCancel = new Command("Cancel", Command.CANCEL, 1);

private final StringItem siKeyHex = new StringItem("HEX", null);
private final StringItem siKeyBase32 = new StringItem("Base32", null);
private final StringItem siKeyBase32 = new StringItem("Base32 (no zeros)", null);
private final StringItem siToken = new StringItem("Token", null);
private final StringItem siProfile = new StringItem(null, null);
private final StringItem siConfirm = new StringItem(null, null);
private final Gauge gauValidity = new Gauge(null, false, DEFAULT_TIMESTEP - 1, DEFAULT_TIMESTEP);
private final TextField tfSecret = new TextField("Secret key (Base32)", null, 105, TextField.ANY);
private final TextField tfSecret = new TextField("Secret key (Base32, no zeros)", null, 105, TextField.ANY);
private final TextField tfProfile = new TextField("Profile name", null, 105, TextField.ANY);
private final TextField tfTimeStep = new TextField("Time step (sec)", String.valueOf(DEFAULT_TIMESTEP), 3,
TextField.NUMERIC);
Expand Down Expand Up @@ -929,7 +929,7 @@ private static String base32Encode(final byte[] bytes) {
if (bytes == null) {
return "";
}
int i = 0, index = 0, digit = 0;
int i = 0, index = 0, digit = 0, outchars = 0;
int currByte, nextByte;
StringBuffer base32 = new StringBuffer((bytes.length + 7) * 8 / 5);

Expand All @@ -956,6 +956,9 @@ private static String base32Encode(final byte[] bytes) {
i++;
}
base32.append(BASE32_CHARS.charAt(digit));
outchars++;
if (outchars % 4 == 0)
base32.append(" ");
}

return base32.toString();
Expand Down Expand Up @@ -1029,10 +1032,12 @@ private static String toHexString(byte[] data, int offset, int length) {
if (data == null || data.length == 0)
return "";

final StringBuffer s = new StringBuffer(length * 2);
final StringBuffer s = new StringBuffer(length * 3);
for (int i = offset; i < offset + length; i++) {
s.append(HEX_TABLE[(data[i] & 0xf0) >>> 4]);
s.append(HEX_TABLE[(data[i] & 0x0f)]);
if ((i - offset) % 2 == 1)
s.append(" ");
}
return s.toString();
}
Expand Down

0 comments on commit 13ffa06

Please sign in to comment.