Use standard charset field

This commit is contained in:
Robinson 2022-03-02 19:26:15 +01:00
parent b0e46b95d5
commit 6135f8380f
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
2 changed files with 5 additions and 6 deletions

View File

@ -21,6 +21,7 @@ import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.Provider; import java.security.Provider;
import java.security.Security; import java.security.Security;
import java.util.Arrays; import java.util.Arrays;
@ -41,8 +42,6 @@ import org.lwjgl.util.xxhash.XXH32State;
import org.lwjgl.util.xxhash.XXHash; import org.lwjgl.util.xxhash.XXHash;
import org.slf4j.Logger; import org.slf4j.Logger;
import dorkbox.os.OS;
/** /**
* http://en.wikipedia.org/wiki/NSA_Suite_B http://www.nsa.gov/ia/programs/suiteb_cryptography/ * http://en.wikipedia.org/wiki/NSA_Suite_B http://www.nsa.gov/ia/programs/suiteb_cryptography/
* <p/> * <p/>
@ -346,7 +345,7 @@ class Crypto {
if (okToHash) { if (okToHash) {
// System.err.println("HASHING: " + name); // System.err.println("HASHING: " + name);
// hash the file name // hash the file name
byte[] bytes = name.getBytes(OS.US_ASCII); byte[] bytes = name.getBytes(StandardCharsets.US_ASCII);
digest.update(bytes, 0, bytes.length); digest.update(bytes, 0, bytes.length);
if (hasAction) { if (hasAction) {

View File

@ -24,6 +24,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchProviderException; import java.security.NoSuchProviderException;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.ArrayList; import java.util.ArrayList;
@ -63,7 +64,6 @@ import org.bouncycastle.openpgp.operator.bc.BcPGPDataEncryptorBuilder;
import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider; import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;
import org.bouncycastle.openpgp.operator.bc.BcPublicKeyKeyEncryptionMethodGenerator; import org.bouncycastle.openpgp.operator.bc.BcPublicKeyKeyEncryptionMethodGenerator;
import dorkbox.os.OS;
import dorkbox.util.IO; import dorkbox.util.IO;
/** /**
@ -601,7 +601,7 @@ class CryptoPGP {
// Encode the string into bytes using utf-8 // Encode the string into bytes using utf-8
byte[] utf8Bytes = message.getBytes(OS.UTF_8); byte[] utf8Bytes = message.getBytes(StandardCharsets.UTF_8);
ByteArrayOutputStream compressedOutput = new ByteArrayOutputStream(); ByteArrayOutputStream compressedOutput = new ByteArrayOutputStream();
@ -797,7 +797,7 @@ class CryptoPGP {
void main(String[] args) throws Exception { void main(String[] args) throws Exception {
InputStream privateKeyInputStream = new FileInputStream(new File("/home/user/dorkbox/sonatype_private.key")); InputStream privateKeyInputStream = new FileInputStream(new File("/home/user/dorkbox/sonatype_private.key"));
byte[] textBytes = "hello".getBytes(OS.UTF_8); byte[] textBytes = "hello".getBytes(StandardCharsets.UTF_8);
byte[] bytes = CryptoPGP.signGpgCompatible(privateKeyInputStream, "Dorkbox <sonatype@dorkbox.com>", new char[0], textBytes); byte[] bytes = CryptoPGP.signGpgCompatible(privateKeyInputStream, "Dorkbox <sonatype@dorkbox.com>", new char[0], textBytes);