Skip to content

Instantly share code, notes, and snippets.

@t-mochizuki
Created December 3, 2015 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t-mochizuki/e3c09c971f8e2020e6d4 to your computer and use it in GitHub Desktop.
Save t-mochizuki/e3c09c971f8e2020e6d4 to your computer and use it in GitHub Desktop.
object Main extends App {
import java.io.FileInputStream
import java.io.InputStreamReader
import java.io.BufferedReader
import java.security.MessageDigest
val md = MessageDigest.getInstance("SHA-1")
// val bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream("./hoge.png")))
val fileInputStream = new FileInputStream("./hoge.png")
Iterator.continually(fileInputStream.read).takeWhile(_ != -1).foreach(x => md.update(x.toByte))
val s = md.digest.map("%02x".format(_)).mkString
println(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment