Documentation
¶
Index ¶
- Variables
- func DecodeAccessKeyID(publicID int) int
- func DecodeAccountID(publicID int) int
- func DecodeGroupID(publicID int) int
- func DecodePolicyID(publicID int) int
- func DecodeRoleID(publicID int) int
- func DecodeUserID(publicID int) int
- func DecryptRange(val, min, max int) int
- func EncodeAccessKeyID(id int) int
- func EncodeAccountID(id int) int
- func EncodeGroupID(id int) int
- func EncodePolicyID(id int) int
- func EncodeRoleID(id int) int
- func EncodeUserID(id int) int
- func EncryptRange(val, min, max int) int
- type FeistelCipher
Constants ¶
This section is empty.
Variables ¶
var ( // UserIDRange: 8 digits [10,000,000, 99,999,999] MinUserID = 10000000 MaxUserID = 99999999 // RoleIDRange: 9 digits [100,000,000, 199,999,999] MinRoleID = 100000000 MaxRoleID = 199999999 // PolicyIDRange: 9 digits [200,000,000, 299,999,999] MinPolicyID = 200000000 MaxPolicyID = 299999999 // GroupIDRange: 9 digits [300,000,000, 399,999,999] MinGroupID = 300000000 MaxGroupID = 399999999 // AccessKeyIDRange: 9 digits [400,000,000, 499,999,999] MinAccessKeyID = 400000000 MaxAccessKeyID = 499999999 // AccountIDRange: 10 digits [1,000,000,000, 2,147,483,647] (Fits in int32) MinAccountID = 1000000000 MaxAccountID = 2147483647 )
var DefaultKey = []byte("arrow2012-secret-key-salt")
DefaultKey is the encryption key for ID obfuscation. In production, this should be configurable.
Functions ¶
func DecodeAccessKeyID ¶
func DecodeAccountID ¶
DecodeAccountID restores 10-digit Public ID to internal ID.
func DecodeGroupID ¶
func DecodePolicyID ¶
func DecodeRoleID ¶
func DecodeUserID ¶
DecodeUserID restores 8-digit Public ID to internal ID.
func DecryptRange ¶
DecryptRange restores value from EncryptRange
func EncodeAccessKeyID ¶
AccessKey Helpers (for ID, not the string key)
func EncodeAccountID ¶
EncodeAccountID maps internal ID to 10-digit Public ID.
func EncodeUserID ¶
EncodeUserID maps internal ID (1, 2...) to 8-digit Public ID.
func EncryptRange ¶
EncryptRange maps a value strictly within [min, max] to another value in [min, max] reversibly. It assumes the input `val` is already within [min, max].
Types ¶
type FeistelCipher ¶
type FeistelCipher struct {
// contains filtered or unexported fields
}
FeistelCipher implements a format-preserving encryption for integers. It maps a 32-bit integer to another 32-bit integer reversibly.
func NewFeistelCipher ¶
func NewFeistelCipher(key []byte) *FeistelCipher
func (*FeistelCipher) Decrypt ¶
func (fc *FeistelCipher) Decrypt(id uint32) uint32
Decrypt restores the original ID
func (*FeistelCipher) Encrypt ¶
func (fc *FeistelCipher) Encrypt(id uint32) uint32
Encrypt obfuscates a uint32 ID