reprogl
1package hashid2
3type HashData struct {4ID int5Hash string6options Option
7}
8
9func (h *HashData) IsUser() bool {10return h.hasUserBit()11}
12
13func (h *HashData) IsMale() bool {14return h.hasMaleBit()15}
16
17func (h *HashData) hasUserBit() bool {18i := int(h.options)19
20return i-((i>>1)<<1) == 121}
22
23func (h *HashData) hasCommentatorBit() bool {24i := int(h.options)25
26return (i>>1)-((i>>2)<<1) == 127}
28
29func (h *HashData) hasMaleBit() bool {30i := int(h.options)31
32return (i>>2)-((i>>3)<<1) == 133}
34
35func (h *HashData) hasFemaleBit() bool {36i := int(h.options)37
38return (i>>3)-((i>>4)<<1) == 139}
40
41func (h *HashData) validOptions() bool {42return ((h.hasUserBit() && !h.hasCommentatorBit()) || (!h.hasUserBit() && h.hasCommentatorBit())) &&43((h.hasMaleBit() && !h.hasFemaleBit()) || (!h.hasMaleBit() && h.hasFemaleBit()))44}
45