File size: 602 Bytes
39f3704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main

import (
	"crypto/sha256"
	"encoding/hex"
	"fmt"
	"io"
	"os"
)

func main() {
	var buf [32]byte
	h := sha256.New()
	lst := make([]any, 0, 64)
	for _, fname := range files {
		f, err := os.Open("assets/" + fname)
		if err != nil {
			panic(err)
		}
		_, err = io.Copy(h, f)
		if err != nil {
			panic(err)
		}
		s := hex.EncodeToString(h.Sum(buf[:0]))
		fmt.Println("sha256 of", fname, "=", s)
		lst = append(lst, s)
		h.Reset()
		f.Close()
	}
	f, err := os.Create("sha256.env")
	if err != nil {
		panic(err)
	}
	_, err = fmt.Fprintf(f, envtmpl, lst...)
	if err != nil {
		panic(err)
	}
}