github.com/wangyougui/gf/v2@v2.6.5/crypto/gcrc32/gcrc32.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/wangyougui/gf.
     6  
     7  // Package gcrc32 provides useful API for CRC32 encryption algorithms.
     8  package gcrc32
     9  
    10  import (
    11  	"hash/crc32"
    12  
    13  	"github.com/wangyougui/gf/v2/util/gconv"
    14  )
    15  
    16  // Encrypt encrypts any type of variable using CRC32 algorithms.
    17  // It uses gconv package to convert `v` to its bytes type.
    18  func Encrypt(v interface{}) uint32 {
    19  	return crc32.ChecksumIEEE(gconv.Bytes(v))
    20  }