Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToPrivateKey(priv []byte) *rsa.PrivateKey
- func BytesToPublicKey(pub []byte) *rsa.PublicKey
- func DecryptWithPrivateKey(cipherText string, priv *rsa.PrivateKey) (string, error)
- func EncryptWithPublicKey(msg []byte, pub *rsa.PublicKey) (string, error)
- func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)
- func RandomKey(length int) string
- func SavePEMKey(fileName string, key *rsa.PrivateKey)
- func SavePublicPEMKey(fileName string, pubkey *rsa.PublicKey)
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 ¶
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 ¶
EncryptWithPublicKey encrypts given []byte, with public key
func GenerateKeyPair ¶
func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)
GenerateKeyPair generates a new key pair
func SavePEMKey ¶
func SavePEMKey(fileName string, key *rsa.PrivateKey)
SavePEMKey saves generated *rsa.PrivateKey to file
func SavePublicPEMKey ¶
SavePublicPEMKey saves generated *rsa.PublicKey to file
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.