mirror of
				https://github.com/Luzifer/ots.git
				synced 2025-10-31 06:09:00 -04:00 
			
		
		
		
	 7aaf7a7f53
			
		
	
	
		7aaf7a7f53
		
			
		
	
	
	
	
		
			
			to prevent loading of scripts which were modified on the network transport Signed-off-by: Knut Ahlers <knut@ahlers.me>
		
			
				
	
	
		
			22 lines
		
	
	
	
		
			366 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
	
		
			366 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package main
 | |
| 
 | |
| import (
 | |
| 	"crypto/sha512"
 | |
| 	"encoding/base64"
 | |
| 	"path"
 | |
| 	"text/template"
 | |
| )
 | |
| 
 | |
| var tplFuncs = template.FuncMap{
 | |
| 	"SRIHash": assetSRIHash,
 | |
| }
 | |
| 
 | |
| func assetSRIHash(assetName string) string {
 | |
| 	data := MustAsset(path.Join("frontend", assetName))
 | |
| 
 | |
| 	h := sha512.New384()
 | |
| 	h.Write(data)
 | |
| 	sum := h.Sum(nil)
 | |
| 
 | |
| 	return "sha384-" + base64.StdEncoding.EncodeToString(sum)
 | |
| }
 |