diff --git a/route/bgp_path.go b/route/bgp_path.go index 6fd0eb32321b1c830dbe52912318948008293e3d..0ab7dc4b2a3f6a23d77be1a0613b68515a5d1604 100644 --- a/route/bgp_path.go +++ b/route/bgp_path.go @@ -232,8 +232,7 @@ func (b *BGPPath) ComputeHash() string { b.LargeCommunities, b.PathIdentifier) - h := sha256.New() - return fmt.Sprintf("%x", h.Sum([]byte(s))) + return fmt.Sprintf("%x", sha256.Sum256([]byte(s))) } // CommunitiesString returns the formated communities diff --git a/route/bgp_test.go b/route/bgp_test.go index 23a7126dfe98cf37d9c5637fd5040a66b2d646a9..2eb017c2a6b33e5174b94cb9d43e4325750e968d 100644 --- a/route/bgp_test.go +++ b/route/bgp_test.go @@ -36,9 +36,9 @@ func TestComputeHash(t *testing.T) { Source: 4, } - assert.Equal(t, "313030093130300931323320343536093009310966616c736509310934095b313233203435365d095b7b33203120327d5d0935e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", p.ComputeHash()) + assert.Equal(t, "45e238420552b88043edb8cb402034466b08d53b49f8e0fedc680747014ddeff", p.ComputeHash()) p.LocalPref = 150 - assert.NotEqual(t, "313030093130300931323320343536093009310966616c736509310934095b313233203435365d095b7b33203120327d5d0935e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", p.ComputeHash()) + assert.NotEqual(t, "45e238420552b88043edb8cb402034466b08d53b49f8e0fedc680747014ddeff", p.ComputeHash()) }