1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-23 03:17:58 +01:00

Move charset utf8 to static constant

This commit is contained in:
Paul Schaub 2020-07-10 18:16:22 +02:00
parent 0f5d7bd9ba
commit 6c449b86af
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -31,6 +31,7 @@ import org.bouncycastle.util.encoders.Hex;
*/ */
public class OpenPgpV4Fingerprint implements CharSequence, Comparable<OpenPgpV4Fingerprint> { public class OpenPgpV4Fingerprint implements CharSequence, Comparable<OpenPgpV4Fingerprint> {
private static final Charset utf8 = Charset.forName("UTF-8");
private final String fingerprint; private final String fingerprint;
/** /**
@ -49,7 +50,7 @@ public class OpenPgpV4Fingerprint implements CharSequence, Comparable<OpenPgpV4F
} }
public OpenPgpV4Fingerprint(@Nonnull byte[] bytes) { public OpenPgpV4Fingerprint(@Nonnull byte[] bytes) {
this(new String(bytes, Charset.forName("UTF-8"))); this(new String(bytes, utf8));
} }
public OpenPgpV4Fingerprint(@Nonnull PGPPublicKey key) { public OpenPgpV4Fingerprint(@Nonnull PGPPublicKey key) {
@ -88,7 +89,7 @@ public class OpenPgpV4Fingerprint implements CharSequence, Comparable<OpenPgpV4F
* @return key id * @return key id
*/ */
public long getKeyId() { public long getKeyId() {
byte[] bytes = Hex.decode(toString().getBytes(Charset.forName("UTF-8"))); byte[] bytes = Hex.decode(toString().getBytes(utf8));
ByteBuffer buf = ByteBuffer.wrap(bytes); ByteBuffer buf = ByteBuffer.wrap(bytes);
// We have to cast here in order to be compatible with java 8 // We have to cast here in order to be compatible with java 8