Documentation
¶
Index ¶
- Constants
- Variables
- func Abs(i int) int
- func CloseLogger()
- func EncryptString(str string, cost int) ([]byte, error)
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateSecureString(n int) (string, error)
- func HashString(s string) int
- func InitLogger(prio int, maxSize int) error
- func Log(in string, priority int) bool
- func LogAndPrint(in string, priority int) bool
- func StringMatchesEncryption(str string, hash []byte) bool
- type Error
Constants ¶
const ( // Shared table defaults DefaultPartitionMax uint16 = 250 PartitionMin uint16 = 1 DefaultMaxEntries uint64 = 0 DefaultEncryptCost int = 4 EncryptCostMax int = 31 EncryptCostMin int = 4 )
const ( FileTypeConfig = ".gdbconf" FileTypeLog = ".gdbl" FileTypeStorage = ".gdbs" )
File types
const ( // Unexpected error ErrorUnexpected = 1000 + iota // Unexpected internal error... // Generic Table Query Errors ErrorTableExists ErrorTableDoesntExist ErrorTableNameRequired ErrorInvalidKeyCharacters ErrorTableFull ErrorQueryInvalidFormat ErrorNoEntryFound )
const ( // Schema creation errors ErrorSchemaRequired = 2001 + iota ErrorSchemaItemsRequired ErrorSchemaInvalidItemName ErrorSchemaInvalidItemPosition ErrorSchemaInvalidItemType ErrorSchemaInvalidItemParameters ErrorSchemaInvalidFormat ErrorSchemaInvalidTimeFormat ErrorSchemaInvalid ErrorObjectItemNotRequired // 2010 // Query Schema errors ErrorInvalidItem ErrorInvalidItemValue ErrorInvalidMethod ErrorInvalidMethodParameters ErrorTooManyMethodParameters ErrorNotEnoughMethodParameters ErrorMissingRequiredItem ErrorStringTooLarge ErrorStringRequired ErrorStringIsEncrypted // 2020 ErrorEncryptingString ErrorArrayItemsRequired ErrorArrayEmpty ErrorArrayItemNotSortable ErrorIndexOutOfBounds ErrorMapItemsRequired ErrorInvalidTimeFormat ErrorUniqueValueDuplicate ErrorRestoreItemSchema )
const ( // Keystore Errors ErrorKeyRequired = 3001 + iota ErrorKeyInUse )
const ( // Auth Table Query Errors ErrorNameRequired = 4001 + iota ErrorNameInUse ErrorInvalidNameCharacters ErrorPasswordLength ErrorPasswordEncryption ErrorNoEmailItem ErrorIncorrectAuthType ErrorInvalidEmail )
const ( // Leaderboard errors ErrorLeaderboardExists = 5001 + iota ErrorLeaderboardDoesntExist )
const ( // Storage errors ErrorStorageNotInitialized = 9001 + iota ErrorTableFolderCreate ErrorCreatingFolder ErrorFileOpen ErrorFileAppend ErrorFileUpdate ErrorFileRead ErrorFileWrite ErrorFileDelete // 6010 ErrorJsonEncoding ErrorJsonDecoding ErrorJsonDataFormat ErrorJsonIndexingFormat ErrorInternalFormatting )
Variables ¶
var (
// Faster JSON Mashaling
Fjson = jsoniter.ConfigCompatibleWithStandardLibrary
)
Functions ¶
func CloseLogger ¶
func CloseLogger()
CloseLogger closes the logger. Any subsequent logs will only be output to the console.
func EncryptString ¶
EncryptString encrypts a `string` with the `golang.org/x/crypto/bcrypt` library at a given cost.
func GenerateRandomBytes ¶
GenerateRandomBytes uses the `crypto/rand` library to create a secure random `[]byte` at a given size `n`.
func GenerateSecureString ¶
GenerateSecureString uses the `crypto/rand` and `encoding/base64` libraries to create a random `string` of given length `n`.
func HashString ¶
HashString hashes a string into a number viable for use as a key
func InitLogger ¶
InitLogger initializes the logging system and returns an error if anything goes wrong. The logger can only be used if it is successfully initialized.
func Log ¶
Log appends the given string to the current log file. If the priority level is less than the minimum priority level threshold, the log will not be written.
func LogAndPrint ¶
func StringMatchesEncryption ¶
StringMatchesEncryption uses the `golang.org/x/crypto/bcrypt` library to compare a `string` to an encrypted `[]byte`. Returns true if the `string` matches the encrypted `[]byte`.