ByteArrayWrapper.wrap(String) no longer uses SHA256 hash of string, it

uses the UTF8 bytes of the string directly.
This commit is contained in:
nathan 2017-07-29 22:17:21 +02:00
parent b129364ee0
commit 47e73efb52

View File

@ -15,8 +15,6 @@
*/
package dorkbox.util.bytes;
import org.bouncycastle.crypto.digests.SHA256Digest;
import java.nio.charset.Charset;
import java.util.Arrays;
@ -83,6 +81,9 @@ class ByteArrayWrapper {
return new ByteArrayWrapper(data, false);
}
/**
* Gets the UTF8 bytes from the string, and wraps them in a ByteArrayWrapper.
*/
public static
ByteArrayWrapper wrap(String data) {
if (data == null) {
@ -90,13 +91,7 @@ class ByteArrayWrapper {
}
byte[] bytes = data.getBytes(UTF_8);
SHA256Digest digest = new SHA256Digest();
digest.update(bytes, 0, bytes.length);
byte[] hashBytes = new byte[digest.getDigestSize()];
digest.doFinal(hashBytes, 0);
return ByteArrayWrapper.wrap(hashBytes);
return ByteArrayWrapper.wrap(bytes);
}
public