sha1HashFile computes a SHA1 hash of the file, returning the hex representation.
(name string)
| 457 | // sha1HashFile computes a SHA1 hash of the file, returning the hex |
| 458 | // representation. |
| 459 | func sha1HashFile(name string) (string, error) { |
| 460 | //#nosec // Not used for cryptography. |
| 461 | hash := sha1.New() |
| 462 | f, err := os.Open(name) |
| 463 | if err != nil { |
| 464 | return "", err |
| 465 | } |
| 466 | defer f.Close() |
| 467 | |
| 468 | _, err = io.Copy(hash, f) |
| 469 | if err != nil { |
| 470 | return "", err |
| 471 | } |
| 472 | |
| 473 | b := make([]byte, hash.Size()) |
| 474 | hash.Sum(b[:0]) |
| 475 | |
| 476 | return hex.EncodeToString(b), nil |
| 477 | } |
| 478 | |
| 479 | func parseSHA1(siteFS fs.FS) (map[string]string, error) { |
| 480 | b, err := fs.ReadFile(siteFS, "bin/coder.sha1") |