gf/g/crypto/gcrc32/gcrc32_test.go

39 lines
941 B
Go
Raw Normal View History

2019-04-05 17:11:03 +08:00
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
// go test *.go -bench=".*"
package gcrc32_test
import (
"testing"
"github.com/gogf/gf/g/crypto/gcrc32"
"github.com/gogf/gf/g/test/gtest"
)
2019-06-10 15:05:11 +08:00
func TestEncryptString(t *testing.T) {
2019-04-05 17:11:03 +08:00
gtest.Case(t, func() {
s := "pibigstar"
2019-04-08 11:53:29 +08:00
result := 693191136
2019-04-05 17:11:03 +08:00
encrypt1 := gcrc32.EncryptString(s)
encrypt2 := gcrc32.EncryptBytes([]byte(s))
2019-04-08 11:53:29 +08:00
gtest.AssertEQ(int(encrypt1), result)
gtest.AssertEQ(int(encrypt2), result)
2019-04-05 17:11:03 +08:00
})
}
2019-06-10 15:05:11 +08:00
func TestEncrypt(t *testing.T) {
gtest.Case(t, func() {
s := "pibigstar"
result := 693191136
encrypt1 := gcrc32.Encrypt(s)
encrypt2 := gcrc32.Encrypt([]byte(s))
gtest.AssertEQ(int(encrypt1), result)
gtest.AssertEQ(int(encrypt2), result)
})
}