Documentation ¶
Index ¶
- func FirstNoneZeroBit(n uint64) uint64
- func MurMurHash64(str string) (val uint64)
- func RevBit(val, num uint64) (revVal uint64)
- type NumMPHType
- type ShuffleType
- func (obj *ShuffleType) Decode(num uint64) (plainNum uint64, err error)
- func (obj *ShuffleType) Encode(num uint64) (cipherNum uint64, err error)
- func (obj *ShuffleType) ExtendDecode(num uint64) (plainNum uint64, err error)
- func (obj *ShuffleType) ExtendEncode(num uint64) (cipherNum uint64, err error)
- func (obj *ShuffleType) Init(min, max uint64, secretKey string) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstNoneZeroBit ¶
FirstNoneZeroBit 计算n的第一个二进制的1的下标值(小端序,从右往左,首位下标为1) 举例:
- n=0,其为0,是以没有下标为1 ==> ret=0
- n=0b0010_1010,其第一个1的下标值为6 ==> ret=6
- n=0b0101,其第一个1的下标值为3 ==> ret=3
- n=0xFFFF_FFFF_FFFF_FFFF,其第一个1的下标值为64 ==> ret=64
func MurMurHash64 ¶
Types ¶
type NumMPHType ¶
type NumMPHType struct {
// contains filtered or unexported fields
}
NumMPHType 完美哈希一段范围的整数(即将这段范围内的整数,做一个shuffle,由于数据空间太大,是以不能用类似52张扑克牌的方式做shuffle)
func (*NumMPHType) Decode ¶
func (obj *NumMPHType) Decode(cipherNum uint64) (plainNum uint64, err error)
Encode 整数解密,输入密文整数,输出明文整数
func (*NumMPHType) Encode ¶
func (obj *NumMPHType) Encode(plainNum uint64) (cipherNum uint64, err error)
Encode 整数加密,输入明文整数,输出密文整数
func (*NumMPHType) GetRange ¶
func (obj *NumMPHType) GetRange() (max uint64)
GetRange 获取能完美hash的最大值 取值范围为[min,max),其为用户想要的取值范围,但是这里要打个折扣,取值范围将会是[min,2^(first_1_bit_idx_from_left-1))
func (*NumMPHType) Init ¶
func (obj *NumMPHType) Init(max uint64, secretKey string)
Init 初始化 取值范围为[min,max),其为用户想 要的取值范围,但是这里要打个折扣,取值范围将会是[min,2^(first_1_bit_idx_from_left-1))
type ShuffleType ¶
type ShuffleType struct {
// contains filtered or unexported fields
}
func (*ShuffleType) Decode ¶
func (obj *ShuffleType) Decode(num uint64) (plainNum uint64, err error)
Encode 解码,num范围必须在Init中[min,max)之内
func (*ShuffleType) Encode ¶
func (obj *ShuffleType) Encode(num uint64) (cipherNum uint64, err error)
Encode 编码,num范围必须在Init中[min,max)之内
func (*ShuffleType) ExtendDecode ¶
func (obj *ShuffleType) ExtendDecode(num uint64) (plainNum uint64, err error)
func (*ShuffleType) ExtendEncode ¶
func (obj *ShuffleType) ExtendEncode(num uint64) (cipherNum uint64, err error)
Click to show internal directories.
Click to hide internal directories.