41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package main
 | 
						|
 | 
						|
import (
 | 
						|
	"crypto/sha256"
 | 
						|
	"encoding/hex"
 | 
						|
	"fmt"
 | 
						|
)
 | 
						|
 | 
						|
func main() {
 | 
						|
	sha1 := []byte("32254b975eb8013394f7f7f3cd90e09aebf4b4489e69150a3260be3a5a7a0562")
 | 
						|
	sha2 := []byte("22254b975eb8013395f7f7f3cd90e09aebf4b4489e69150a3260be3a5a7a0562")
 | 
						|
	bytes1 := sha256.Sum256(sha1)
 | 
						|
	bytes2 := sha256.Sum256(sha2)
 | 
						|
	var shaList [][32]byte
 | 
						|
	shaList = append(shaList, bytes1)
 | 
						|
	shaList = append(shaList, bytes2)
 | 
						|
 | 
						|
	//var hashList [][]byte
 | 
						|
	hasher := sha256.New()
 | 
						|
	for _, file := range shaList {
 | 
						|
		hasher.Write(file[:])
 | 
						|
	}
 | 
						|
	commitMessage := "This is a commit message2!"
 | 
						|
	//time := time.Now()
 | 
						|
	//hasher.Write([]byte(commitMessage + time.String()))
 | 
						|
	hasher.Write([]byte(commitMessage))
 | 
						|
	//commitMeta := []byte(commitMessage + time.String()) //TODO add author and other things
 | 
						|
	//commitMetaHash := sha256.Sum256(commitMeta)
 | 
						|
	fmt.Println("Hashbytes: ", hasher.Sum(nil))
 | 
						|
 | 
						|
	fullHash := hex.EncodeToString(hasher.Sum(nil))
 | 
						|
	fmt.Println("Hasher: ", fullHash)
 | 
						|
	// if _, err := hasher.Write([]byte(commitMessage + time.String())); err != nil { // Create a hash of the message and time
 | 
						|
	// 	return err
 | 
						|
	// }
 | 
						|
	//hashList = append(hashList, commitMetaHash) // add that to the tree
 | 
						|
	//testhash := hashList[:]
 | 
						|
	//commitHash := sha256.Sum256(hashList[:])
 | 
						|
 | 
						|
}
 |