()
| 38 | } |
| 39 | |
| 40 | func (c *sha1Checksum) ComputeFileSha1() ([]byte, error) { |
| 41 | hash := sha1.New() |
| 42 | |
| 43 | f, err := os.Open(c.filepath) |
| 44 | if err != nil { |
| 45 | return []byte{}, err |
| 46 | } |
| 47 | defer f.Close() |
| 48 | |
| 49 | if _, err := io.Copy(hash, f); err != nil { |
| 50 | return []byte{}, err |
| 51 | } |
| 52 | |
| 53 | return hash.Sum(nil), nil |
| 54 | } |
| 55 | |
| 56 | func (c *sha1Checksum) SetFilePath(filepath string) { |
| 57 | c.filepath = filepath |