mirror of
https://github.com/pgsty/minio.git
synced 2026-08-09 15:53:28 +03:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user