Documentation ¶
Overview ¶
Package helper contains various small helper functions
Index ¶
- Constants
- func Format(b []byte) template.HTML
- func GetRealIP(r *http.Request) string
- func Hash(data []byte) (hash, salt []byte, err error)
- func HashForSalt(data, salt []byte) (hash []byte)
- func HidePassword(pw string) string
- func UnhidePassword(pw string) (string, error)
- func VerifyHash(data, hash, salt []byte) bool
Constants ¶
const ConfigInvalid template.HTML = `<h1 style="color: red;">☒ configuration not valid</h1>`
ConfigInvalid holds a HTML fragment which can be displayed when the plugin configuration is not valid. Use this to get a consistent look.
const ConfigValid template.HTML = `<h1 style="color: green;">☑ configuration valid</h1>`
ConfigValid holds a HTML fragment which can be displayed when the plugin configuration is valid. Use this to get a consistent look.
Variables ¶
This section is empty.
Functions ¶
func GetRealIP ¶
GetRealIP tries to fing the real IP address of a client. If an error is found, that error will be returned instead of an IP address. A reverse proxy is only assumed if address is a loopback device (to avoid spoofing)
func HashForSalt ¶
HashForSalt creates a hash of the data. You have to provide a salt for the hash.
func HidePassword ¶
HidePassword encodes the password in a way it is no longer human readable. This function is easily reverseable. Its sole purpose is to not save passwords as clear text on disks (to avoid an accidental read). It provides no security against an attacker or bad actor.
func UnhidePassword ¶
UnhidePassword reveals a hidden password. See HidePassword for more information.
func VerifyHash ¶
VerifyHash returns whether the data and the hash correspond (given the salt).
Types ¶
This section is empty.