mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-08 23:48:03 +08:00
添加 github.com/pion/dtls 代码
This commit is contained in:
25
dtls-2.0.9/pkg/crypto/hash/hash_test.go
Normal file
25
dtls-2.0.9/pkg/crypto/hash/hash_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package hash
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/pion/dtls/v2/pkg/crypto/fingerprint"
|
||||
)
|
||||
|
||||
func TestHashAlgorithm_StringRoundtrip(t *testing.T) {
|
||||
for algo := range Algorithms() {
|
||||
if algo == Ed25519 || algo == None {
|
||||
continue
|
||||
}
|
||||
|
||||
str := algo.String()
|
||||
hash1 := algo.CryptoHash()
|
||||
hash2, err := fingerprint.HashFromString(str)
|
||||
if err != nil {
|
||||
t.Fatalf("fingerprint.HashFromString failed: %v", err)
|
||||
}
|
||||
if hash1 != hash2 {
|
||||
t.Errorf("Hash algorithm mismatch, input: %d, after roundtrip: %d", int(hash1), int(hash2))
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user