Implement md5c function, slower than Golang's implementation

keeping it in repo to make further improvements and also rename

        minio-hash ---> crypto
This commit is contained in:
Harshavardhana
2014-12-21 02:12:30 -08:00
parent 958890276d
commit 13650e088c
11 changed files with 449 additions and 17 deletions
+6 -1
View File
@@ -8,10 +8,15 @@ import (
func Sum(reader io.Reader) ([]byte, error) {
hash := md5.New()
var err error
var length int
for err == nil {
length := 0
byteBuffer := make([]byte, 1024*1024)
length, err = reader.Read(byteBuffer)
// While hash.Write() wouldn't mind a Nil byteBuffer
// It is necessary for us to verify this and break
if length == 0 {
break
}
byteBuffer = byteBuffer[0:length]
hash.Write(byteBuffer)
}