helper

package
v0.0.0-...-5722567 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Overview

Package helper contains various small helper functions

Index

Constants

View Source
const ConfigInvalid template.HTML = `<h1 style="color: red;">&#9746; 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.

View Source
const ConfigValid template.HTML = `<h1 style="color: green;">&#9745; 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 Format

func Format(b []byte) template.HTML

Format returns a save html version of the Markdown input.

func GetRealIP

func GetRealIP(r *http.Request) string

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 Hash

func Hash(data []byte) (hash, salt []byte, err error)

Hash creates a hash of the data. The function will create a salt for the hash.

func HashForSalt

func HashForSalt(data, salt []byte) (hash []byte)

HashForSalt creates a hash of the data. You have to provide a salt for the hash.

func HidePassword

func HidePassword(pw string) string

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

func UnhidePassword(pw string) (string, error)

UnhidePassword reveals a hidden password. See HidePassword for more information.

func VerifyHash

func VerifyHash(data, hash, salt []byte) bool

VerifyHash returns whether the data and the hash correspond (given the salt).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL