/MessageHash.scala Secret
Created
December 3, 2015 11:44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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