示例#1
0
func (tsd *Digest) Reset() {
	tsd.headerBuffer.Reset()
	tsd.currentBuffer.Reset()

	tsd.digestStage = stageReadHeader
	tsd.tarReader = new(tar.Reader)
	tsd.entryHash = sha256.New()
	tsd.sums = fileInfoSums{}
	tsd.fileCounter = 0
	tsd.bytesWritten = 0
	tsd.currentFilename = ""
	tsd.pad = 0
	tsd.err = nil
}
示例#2
0
func (tsd *Digest) Sum(extra []byte) []byte {
	tsd.sums.SortBySums()
	hasher := sha256.New()

	if extra != nil {
		hasher.Write(extra)
	}

	for _, fis := range tsd.sums {
		hasher.Write([]byte(fis.Sum()))
	}

	return hasher.Sum(nil)
}
示例#3
0
func (tsd *Digest) BlockSize() int {
	return sha256.New().BlockSize()
}
示例#4
0
func (tsd *Digest) Size() int {
	return sha256.New().Size()
}