Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed hashing of files

  • Loading branch information...
commit 0ee0ad15fc95b1cfa72159e5931265b9f3bbc313 1 parent 405588c
@gklopper gklopper authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/main/scala/com.gu.deploy/package.scala
View
14 src/main/scala/com.gu.deploy/package.scala
@@ -6,6 +6,9 @@ import org.apache.commons.codec.digest.DigestUtils
import org.apache.commons.io.IOUtils
import sbt._
import scala.collection.JavaConversions._
+import com.google.common.io.Files
+import java.security.MessageDigest
+import org.apache.commons.codec.binary.Hex
object `package` {
@@ -17,10 +20,6 @@ object `package` {
}
}
- implicit def string2Md5Hex(s: String) = new {
- lazy val md5Hex: String = DigestUtils md5Hex s
- }
-
implicit def string2IndentContinuationLines(s: String) = new {
lazy val indentContinuationLines: String = s.replaceAll("\n", "\n\t\t")
}
@@ -40,8 +39,11 @@ object `package` {
}
implicit def file2Md5Hex(file: File) = new {
- def contents: String = using(new FileInputStream(file)) { IOUtils toString _ }
- def md5Hex = contents.md5Hex
+ def md5Hex = new String(Hex.encodeHex(Files.getDigest(file, MessageDigest.getInstance("MD5"))))
+ }
+
+ implicit def string2Md5Hex(s: String) = new {
+ def md5Hex = DigestUtils.md5Hex(s)
}
implicit def seq2UpdateWith[V](seq: Seq[V]) = new {
Please sign in to comment.
Something went wrong with that request. Please try again.