github.com/zhongdalu/gf@v1.0.0/g/crypto/gcrc32/gcrc32.go (about) 1 // Copyright 2017 gf Author(https://github.com/zhongdalu/gf). 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/zhongdalu/gf. 6 7 // Package gcrc32 provides useful API for CRC32 encryption algorithms. 8 package gcrc32 9 10 import ( 11 "github.com/zhongdalu/gf/g/util/gconv" 12 "hash/crc32" 13 ) 14 15 // Encrypt encrypts any type of variable using CRC32 algorithms. 16 // It uses gconv package to convert <v> to its bytes type. 17 func Encrypt(v interface{}) uint32 { 18 return crc32.ChecksumIEEE(gconv.Bytes(v)) 19 } 20 21 // Deprecated. 22 func EncryptString(v string) uint32 { 23 return crc32.ChecksumIEEE([]byte(v)) 24 } 25 26 // Deprecated. 27 func EncryptBytes(v []byte) uint32 { 28 return crc32.ChecksumIEEE(v) 29 }