package precis

Import Path
	golang.org/x/text/secure/precis (on go.dev)

Dependency Relation
	imports 11 packages, and imported by one package

Involved Source Files class.go context.go Package precis contains types and functions for the preparation, enforcement, and comparison of internationalized strings ("PRECIS") as defined in RFC 8264. It also contains several pre-defined profiles for passwords, nicknames, and usernames as defined in RFC 8265 and RFC 8266. BE ADVISED: This package is under construction and the API may change in backwards incompatible ways and without notice. nickname.go options.go profile.go profiles.go tables15.0.0.go transformer.go trieval.go
Package-Level Type Names (total 3)
/* sort by: | */
An Option is used to define the behavior and rules of a Profile. func AdditionalMapping(t ...func() transform.Transformer) Option func Disallow(set runes.Set) Option func FoldCase(opts ...cases.Option) Option func LowerCase(opts ...cases.Option) Option func Norm(f norm.Form) Option func NewFreeform(opts ...Option) *Profile func NewIdentifier(opts ...Option) *Profile var BidiRule var DisallowEmpty var FoldWidth var IgnoreCase
A Profile represents a set of rules for normalizing and validating strings in the PRECIS framework. Allowed returns a runes.Set containing every rune that is a member of the underlying profile's string class and not disallowed by any profile specific rules. Append appends the result of applying p to src writing the result to dst. It returns an error if the input string is invalid. AppendCompareKey appends the result of applying p to src (including any optional rules to make strings comparable or useful in a map key such as applying lowercasing) writing the result to dst. It returns an error if the input string is invalid. Bytes returns a new byte slice with the result of applying the profile to b. Compare enforces both strings, and then compares them for bit-string identity (byte-for-byte equality). If either string cannot be enforced, the comparison is false. CompareKey returns a string that can be used for comparison, hashing, or collation. NewTransformer creates a new transform.Transformer that performs the PRECIS preparation and enforcement steps on the given UTF-8 encoded bytes. String returns a string with the result of applying the profile to s. func NewFreeform(opts ...Option) *Profile func NewIdentifier(opts ...Option) *Profile func NewRestrictedProfile(parent *Profile, disallow runes.Set) *Profile func NewRestrictedProfile(parent *Profile, disallow runes.Set) *Profile var Nickname *Profile var OpaqueString *Profile var UsernameCaseMapped *Profile var UsernameCasePreserved *Profile
Transformer implements the transform.Transformer interface. Bytes returns a new byte slice with the result of applying t to b. Reset implements the transform.Transformer interface. String returns a string with the result of applying t to s. Transform implements the transform.Transformer interface. Transformer : golang.org/x/text/transform.Transformer Transformer : vendor/golang.org/x/text/transform.Transformer func (*Profile).NewTransformer() *Transformer
Package-Level Functions (total 8)
The AdditionalMapping option defines the additional mapping rule for the Profile by applying Transformer's in sequence.
The Disallow option further restricts a Profile's allowed characters beyond what is disallowed by the underlying string class.
The FoldCase option defines a Profile's case mapping rule. Options can be provided to determine the type of case folding used.
The LowerCase option defines a Profile's case mapping rule. Options can be provided to determine the type of case folding used.
NewFreeform creates a new PRECIS profile based on the Freeform string class. Profiles created from this class are suitable for use where expressiveness is prioritized over safety like passwords, and display-elements such as nicknames in a chat room.
NewIdentifier creates a new PRECIS profile based on the Identifier string class. Profiles created from this class are suitable for use where safety is prioritized over expressiveness like network identifiers, user accounts, chat rooms, and file names.
NewRestrictedProfile creates a new PRECIS profile based on an existing profile. If the parent profile already had the Disallow option set, the new rule overrides the parents rule.
The Norm option defines a Profile's normalization rule. Defaults to NFC.
Package-Level Variables (total 8)
The BidiRule option causes the Bidi Rule defined in RFC 5893 to be applied.
The DisallowEmpty option causes the enforcement step to return an error if the resulting string would be empty.
The FoldWidth option causes the profile to map non-canonical wide and narrow variants to their decomposition mapping. This is useful for profiles that are based on the identifier class which would otherwise disallow such characters.
The IgnoreCase option causes the profile to perform a case insensitive comparison during the PRECIS comparison step.
Implements the Nickname profile specified in RFC 8266.
Implements the OpaqueString profile defined in RFC 8265 for passwords and other secure labels.
Implements the UsernameCaseMapped profile specified in RFC 8265.
Implements the UsernameCasePreserved profile specified in RFC 8265.
Package-Level Constants (only one)
UnicodeVersion is the Unicode version from which the tables in this package are derived.