|
30 | 30 | import java.nio.file.Paths; |
31 | 31 | import java.security.MessageDigest; |
32 | 32 | import java.security.NoSuchAlgorithmException; |
| 33 | +import java.security.SecureRandom; |
33 | 34 | import java.util.Collection; |
34 | 35 | import java.util.Collections; |
35 | 36 | import java.util.Optional; |
|
39 | 40 | import org.apache.commons.compress.archivers.tar.TarArchiveEntry; |
40 | 41 | import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; |
41 | 42 | import org.apache.commons.compress.utils.IOUtils; |
42 | | -import org.apache.commons.lang3.RandomStringUtils; |
43 | 43 | import org.apache.commons.lang3.StringUtils; |
44 | 44 | import org.apache.hadoop.conf.Configuration; |
45 | 45 | import org.apache.hadoop.hdds.scm.HddsServerUtil; |
|
70 | 70 | */ |
71 | 71 | public final class OmUtils { |
72 | 72 | public static final Logger LOG = LoggerFactory.getLogger(OmUtils.class); |
| 73 | + private static final SecureRandom SRAND = new SecureRandom(); |
| 74 | + private static byte[] randomBytes = new byte[32]; |
73 | 75 |
|
74 | 76 | private OmUtils() { |
75 | 77 | } |
@@ -246,9 +248,9 @@ public static byte[] getMD5Digest(String input) throws IOException { |
246 | 248 |
|
247 | 249 | public static byte[] getSHADigest() throws IOException { |
248 | 250 | try { |
| 251 | + SRAND.nextBytes(randomBytes); |
249 | 252 | MessageDigest sha = MessageDigest.getInstance(OzoneConsts.FILE_HASH); |
250 | | - return sha.digest(RandomStringUtils.random(32) |
251 | | - .getBytes(StandardCharsets.UTF_8)); |
| 253 | + return sha.digest(randomBytes); |
252 | 254 | } catch (NoSuchAlgorithmException ex) { |
253 | 255 | throw new IOException("Error creating an instance of SHA-256 digest.\n" + |
254 | 256 | "This could possibly indicate a faulty JRE"); |
|
0 commit comments