Skip to content

Commit f3fd20d

Browse files
fix::> removed
Signed-off-by: Abhinav Prakash <abhinav.prakash319@gmail.com>
1 parent f8b4993 commit f3fd20d

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package utils
2+
3+
import (
4+
"crypto/sha256"
5+
"encoding/hex"
6+
"fmt"
7+
)
8+
9+
// Deal eveyting in bytes to keep things generic and simple
10+
func SHA256Hash(data []byte) string {
11+
hash := sha256.Sum256(data)
12+
return hex.EncodeToString(hash[:])
13+
}
14+
15+
// Hash/secret Verification
16+
func VerifyHash(data []byte, expected string) bool {
17+
return SHA256Hash(data) == expected
18+
}
19+
20+
func HashCertificate(cert []byte) string {
21+
return SHA256Hash(cert)
22+
}
23+
24+
func VerifySecret(secret string, expected string) bool {
25+
return VerifyHash([]byte(secret), expected)
26+
}
27+
28+
// CreateCompositeKey creates a deterministic composite key
29+
// Useful for creating unique identifiers
30+
func CreateCompositeKey(components ...string) string {
31+
var combined string
32+
for i, component := range components {
33+
if i > 0 {
34+
combined += ":"
35+
}
36+
combined += component
37+
}
38+
return SHA256Hash([]byte(combined))
39+
}
40+
41+
func LogHashOperation(operation string, input string, output string) {
42+
fmt.Printf("[CRYPTO] %s: %s -> %s\n", operation, input[:min(len(input), 10)]+"...", output[:16]+"...")
43+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package utils
2+
3+
import (
4+
"github.com/hyperledger-labs/cc-tools/errors"
5+
)
6+
7+
func GenerateUUID() (string, errors.ICCError) {
8+
return "todo", nil
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package utils
2+
3+
// will think of it.
4+
// mainly created for field validation..

0 commit comments

Comments
 (0)