Skip to content

Commit 043c843

Browse files
committed
Internal refactoring
1 parent 00bfe4a commit 043c843

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • src/main/java/org/apache/commons/codec/binary

src/main/java/org/apache/commons/codec/binary/Base58.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
*/
5454
public class Base58 extends BaseNCodec {
5555

56+
private static final BigInteger BASE = BigInteger.valueOf(58);
5657
private static final byte[] EMPTY = new byte[0];
5758

5859
/**
@@ -156,7 +157,6 @@ private void convertFromBase58(final byte[] base58Data, final Context context) {
156157
}
157158
leadingOnes++;
158159
}
159-
final BigInteger base = BigInteger.valueOf(58);
160160
BigInteger power = BigInteger.ONE;
161161
for (int i = base58Data.length - 1; i >= leadingOnes; i--) {
162162
final byte b = base58Data[i];
@@ -165,7 +165,7 @@ private void convertFromBase58(final byte[] base58Data, final Context context) {
165165
throw new IllegalArgumentException(String.format("Invalid character in Base58 string: 0x%02x", b));
166166
}
167167
value = value.add(BigInteger.valueOf(digit).multiply(power));
168-
power = power.multiply(base);
168+
power = power.multiply(BASE);
169169
}
170170
byte[] decoded = value.toByteArray();
171171
if (decoded.length > 1 && decoded[0] == 0) {
@@ -288,7 +288,7 @@ private StringBuilder getStringBuilder(final byte[] accumulate) {
288288
}
289289
final StringBuilder base58 = new StringBuilder();
290290
while (value.signum() > 0) {
291-
final BigInteger[] divRem = value.divideAndRemainder(BigInteger.valueOf(58));
291+
final BigInteger[] divRem = value.divideAndRemainder(BASE);
292292
base58.append((char) ENCODE_TABLE[divRem[1].intValue()]);
293293
value = divRem[0];
294294
}

0 commit comments

Comments
 (0)