{"modulePath":"github.com/devaccuracy/ledgerforge","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package tokenization\n\n## Variables\n\n```go\nvar ErrTokenizationDisabled = errors.New(\n\t\"tokenization is disabled: LEDGERFORGE_TOKENIZATION_SECRET or tokenization_secret in your ledgerforge.json file must be set to a 32-byte value\",\n)\n```\n\n```go\nvar TokenizableFields = []string{\n\t\"FirstName\",\n\t\"LastName\",\n\t\"OtherNames\",\n\t\"EmailAddress\",\n\t\"PhoneNumber\",\n\t\"Street\",\n\t\"PostCode\",\n}\n```\nTokenizableFields defines which fields can be tokenized in the Identity model\n\n## Types\n\n```go\ntype TokenizationMode int\n```\nTokenizationMode defines the type of tokenization to use\n\n```go\nconst (\n\t// StandardMode uses regular AES-GCM encryption with base64 encoding\n\tStandardMode TokenizationMode = iota\n\n\t// FormatPreservingMode maintains the format of the original data\n\tFormatPreservingMode\n)\n```\n\n```go\ntype TokenizationService struct {\n\t// contains filtered or unexported fields\n}\n```\nTokenizationService handles converting PII to tokens and back\n\n```go\nfunc NewTokenizationService(encryptionKey []byte) *TokenizationService\n```\nNewTokenizationService creates a new tokenization service.\n\nParameters: - encryptionKey \\[]byte: The encryption key used for tokenization.\n\nReturns: - \\*TokenizationService: A new instance of TokenizationService.\n\n```go\nfunc (s *TokenizationService) Detokenize(token string) (string, error)\n```\nDetokenize converts a token back to the original PII value using automatic mode detection.\n\nParameters: - token string: The token to be converted back to PII.\n\nReturns: - string: The original PII value. - error: An error if detokenization fails.\n\n```go\nfunc (s *TokenizationService) DetokenizeWithMode(token string, mode TokenizationMode) (string, error)\n```\nDetokenizeWithMode converts a token back to the original PII value using the specified mode.\n\nParameters: - token string: The token to be converted back to PII. - mode TokenizationMode: The tokenization mode to use.\n\nReturns: - string: The original PII value. - error: An error if detokenization fails.\n\n```go\nfunc (s *TokenizationService) Tokenize(value string) (string, error)\n```\nTokenize converts a PII value to a token using the default standard mode.\n\nParameters: - value string: The original PII value to be tokenized.\n\nReturns: - string: The tokenized value. - error: An error if tokenization fails.\n\n```go\nfunc (s *TokenizationService) TokenizeWithMode(value string, mode TokenizationMode) (string, error)\n```\nTokenizeWithMode converts a PII value to a token using the specified mode.\n\nParameters: - value string: The original PII value to be tokenized. - mode TokenizationMode: The tokenization mode to use.\n\nReturns: - string: The tokenized value. - error: An error if tokenization fails.\n\n","path":"github.com/devaccuracy/ledgerforge/internal/tokenization","name":"tokenization","synopsis":"","isRedistributable":true}
