Initial commit

This commit is contained in:
puck 2024-10-03 23:57:22 +00:00
commit 55a1efa08f
60 changed files with 5485 additions and 0 deletions

View file

@ -0,0 +1,52 @@
package main
import (
"archive/zip"
"crypto/sha256"
"fmt"
"io"
"os"
"sort"
)
func main() {
out, err := os.OpenFile(os.Getenv("out"), os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
panic(err)
}
var files []string
f, err := zip.OpenReader(os.Getenv("src"))
if err != nil {
panic(err)
}
for _, file := range f.File {
if file.Mode().IsDir() {
continue
}
files = append(files, file.Name)
}
sort.Strings(files)
for _, rel := range files {
f, err := f.Open(rel)
if err != nil {
panic(err)
}
defer f.Close()
hash := sha256.New()
_, err = io.Copy(hash, f)
if err != nil {
panic(err)
}
fmt.Fprintf(out, "%x %s\n", hash.Sum(nil), rel)
}
out.Close()
f.Close()
}