Otp: Remove string concatenation from calculation hot path
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
parent
30b6d2346a
commit
daafc01ce2
1 changed files with 3 additions and 3 deletions
|
@ -43,13 +43,13 @@ public class Otp {
|
|||
code[0] = (byte) (0x7f & code[0]);
|
||||
String strCode = new BigInteger(code).toString();
|
||||
if (digits.equals("s")) {
|
||||
String output = "";
|
||||
StringBuilder output = new StringBuilder();
|
||||
int bigInt = new BigInteger(code).intValue();
|
||||
for (int i = 0; i != 5; i++) {
|
||||
output += steam[bigInt % 26];
|
||||
output.append(steam[bigInt % 26]);
|
||||
bigInt /= 26;
|
||||
}
|
||||
return output;
|
||||
return output.toString();
|
||||
}
|
||||
else return strCode.substring(strCode.length() - Integer.parseInt(digits));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue