basic common app packages

This commit is contained in:
2025-06-16 22:19:00 +05:30
parent 8654f21b62
commit 0240ec154e
49 changed files with 5481 additions and 232 deletions

27
crypto/hash.go Normal file
View File

@@ -0,0 +1,27 @@
package crypto
import (
"crypto/md5"
"crypto/sha256"
"encoding/hex"
)
// MD5 is generally faster to compute than SHA-256
func MD5(b []byte) string {
hash := md5.Sum(b)
return hex.EncodeToString(hash[:])
}
/*
func MD5Int(b []byte) uint64 {
n := new(big.Int)
n.SetString(MD5(b), 16)
return n.Uint64()
}
*/
// SHA256 Sum256 is generally preferred over md5.hash due to its superior security and resistance to collision attacks
func SHA256(b []byte) string {
hash := sha256.Sum256(b)
return hex.EncodeToString(hash[:])
}