github.com/gogf/gf/v2@v2.7.4/crypto/gcrc32/gcrc32_z_unit_test.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 // go test *.go -bench=".*" 8 9 package gcrc32_test 10 11 import ( 12 "testing" 13 14 "github.com/gogf/gf/v2/crypto/gcrc32" 15 "github.com/gogf/gf/v2/crypto/gmd5" 16 "github.com/gogf/gf/v2/test/gtest" 17 ) 18 19 func TestEncrypt(t *testing.T) { 20 gtest.C(t, func(t *gtest.T) { 21 s := "pibigstar" 22 result := 693191136 23 encrypt1 := gcrc32.Encrypt(s) 24 encrypt2 := gcrc32.Encrypt([]byte(s)) 25 t.AssertEQ(int(encrypt1), result) 26 t.AssertEQ(int(encrypt2), result) 27 28 strmd5, _ := gmd5.Encrypt(s) 29 test1 := gcrc32.Encrypt(strmd5) 30 test2 := gcrc32.Encrypt([]byte(strmd5)) 31 t.AssertEQ(test2, test1) 32 }) 33 }