Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #195 from ahus1/2_0_x

Optimed MD5 calculation to be blockwise as bytewise operation is slow
  • Loading branch information...
commit 239cd4f5c73a12cc508a3903bdabc923d299c413 2 parents a7e0d15 + ebf33a6
@nvoxland nvoxland authored
Showing with 6 additions and 5 deletions.
  1. +6 −5 liquibase-core/src/main/java/liquibase/util/MD5Util.java
View
11 liquibase-core/src/main/java/liquibase/util/MD5Util.java
@@ -34,7 +34,7 @@ public static String computeMD5(String input) {
byte[] digestBytes = digest.digest();
String returnString = new String(encodeHex(digestBytes));
- LogFactory.getLogger().debug("Computed checksum for "+input+" as "+returnString);
+ LogFactory.getLogger().debug("Computed checksum for " + input + " as " + returnString);
return returnString;
}
@@ -45,8 +45,9 @@ public static String computeMD5(InputStream stream) {
digest = MessageDigest.getInstance("MD5");
DigestInputStream digestStream = new DigestInputStream(stream, digest);
- while (digestStream.read() != -1) {
- ; //digest is updating
+ byte[] buf = new byte[20480];
+ while (digestStream.read(buf) != -1) {
+ ; // digest is updating
}
} catch (Exception e) {
throw new RuntimeException(e);
@@ -55,7 +56,7 @@ public static String computeMD5(InputStream stream) {
String returnString = new String(encodeHex(digestBytes));
- LogFactory.getLogger().debug("Computed checksum for "+returnString+" as "+returnString);
+ LogFactory.getLogger().debug("Computed checksum for " + returnString + " as " + returnString);
return returnString;
}
@@ -63,7 +64,7 @@ public static String computeMD5(InputStream stream) {
* Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
* The returned array will be double the length of the passed array, as it takes two characters to represent any
* given byte.
- *
+ *
* @param data
* a byte[] to convert to Hex characters
* @return A char[] containing hexadecimal characters
Please sign in to comment.
Something went wrong with that request. Please try again.