|
17 | 17 |
|
18 | 18 | package org.apache.commons.codec.digest; |
19 | 19 |
|
20 | | -import java.nio.charset.Charset; |
21 | | -import java.nio.charset.StandardCharsets; |
| 20 | +import org.apache.commons.codec.binary.StringUtils; |
22 | 21 |
|
23 | 22 | /** |
24 | 23 | * Implementation of the MurmurHash2 32-bit and 64-bit hash functions. |
|
51 | 50 | */ |
52 | 51 | public final class MurmurHash2 { |
53 | 52 |
|
54 | | - /** |
55 | | - * Default Charset used to convert strings into bytes. |
56 | | - * |
57 | | - * Consider private; package private for tests only. |
58 | | - */ |
59 | | - static final Charset GET_BYTES_CHARSET = StandardCharsets.UTF_8; |
60 | | - |
61 | 53 | // Constants for 32-bit variant |
62 | 54 | private static final int M32 = 0x5bd1e995; |
63 | 55 | private static final int R32 = 24; |
@@ -154,7 +146,7 @@ public static int hash32(final byte[] data, final int length) { |
154 | 146 | * @see #hash32(byte[], int, int) |
155 | 147 | */ |
156 | 148 | public static int hash32(final String text) { |
157 | | - final byte[] bytes = text.getBytes(GET_BYTES_CHARSET); |
| 149 | + final byte[] bytes = StringUtils.getBytesUtf8(text); |
158 | 150 | return hash32(bytes, bytes.length); |
159 | 151 | } |
160 | 152 |
|
@@ -268,7 +260,7 @@ public static long hash64(final byte[] data, final int length) { |
268 | 260 | * @see #hash64(byte[], int, int) |
269 | 261 | */ |
270 | 262 | public static long hash64(final String text) { |
271 | | - final byte[] bytes = text.getBytes(GET_BYTES_CHARSET); |
| 263 | + final byte[] bytes = StringUtils.getBytesUtf8(text); |
272 | 264 | return hash64(bytes, bytes.length); |
273 | 265 | } |
274 | 266 |
|
|
0 commit comments