util

package
v0.0.0-...-0ae9f9e Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicPem           = "public.pem"
	PrivatePem          = "private.pem"
	AccessTokenTable    = "oauth_access_tokens"
	RefreshTokenTable   = "oauth_refresh_tokens"
	ClientTable         = "oauth_clients"
	BitSize             = 2048
	RefreshTokenRevoked = "refresh token already been revoked"
	AccessTokenRevoked  = "access token has already been revoked"
	AccessTokenExpired  = "access token has already been expired"
	InvalidRefreshToken = "invalid refresh token"
	InvalidAccessToken  = "invalid access token"
	InvalidClient       = "invalid client"
	EmptyUserID         = "user id cannot be empty"
	Label               = "OAEP Encrypted"
	PublicKey           = "PUBLIC KEY"
	PrivateKey          = "PRIVATE KEY"
	DbConfig            = "root:@tcp(127.0.0.1:3306)/goauth?charset=utf8&parseTime=True&loc=Local"
)

constants

Variables

View Source
var RandomKeyCharacters = []byte("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")

RandomKeyCharacters is random key characters to choose from

Functions

func BytesToPrivateKey

func BytesToPrivateKey(priv []byte) *rsa.PrivateKey

BytesToPrivateKey converts given bytes to *rsa.PrivateKey

func BytesToPublicKey

func BytesToPublicKey(pub []byte) *rsa.PublicKey

BytesToPublicKey converts given bytes to *rsa.PublicKey

func DecryptWithPrivateKey

func DecryptWithPrivateKey(cipherText string, priv *rsa.PrivateKey) (string, error)

DecryptWithPrivateKey decrypts given []byte, with private key

func EncryptWithPublicKey

func EncryptWithPublicKey(msg []byte, pub *rsa.PublicKey) (string, error)

EncryptWithPublicKey encrypts given []byte, with public key

func GenerateKeyPair

func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)

GenerateKeyPair generates a new key pair

func RandomKey

func RandomKey(length int) string

RandomKey generates random characters from RandomKeyCharacters

func SavePEMKey

func SavePEMKey(fileName string, key *rsa.PrivateKey)

SavePEMKey saves generated *rsa.PrivateKey to file

func SavePublicPEMKey

func SavePublicPEMKey(fileName string, pubkey *rsa.PublicKey)

SavePublicPEMKey saves generated *rsa.PublicKey to file

Types

This section is empty.

Jump to

Keyboard shortcuts

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