I am searching for a library in Go that can give to me the capability of crypting for send and decrypting for reading a JWT that I send when a user is logged in my api rest made in Golang.
I have seen a lot of examples with AES, but I have a lot of issues trying to encrypt in AES a JWT because signs like "." or "-" give me problems.
I know that I must use a 32 bytes key, that I can change the base to 64. But only using the most simple example, making a simple hash, using the cipher, I have always the same error at crypting/decrypting.
For instance :
crypto/aes: invalid key size X
I use the same code like this Stack Overflow answer :AES Encryption Golang and Python
I have already my token signed, I want to add a new level of security after signing.
claims := Claim{
User: user,
StandardClaims: djwt.StandardClaims{
ExpiresAt: time.Now().Add(time.Hour * 1).Unix(),
Issuer: "App Timer",
},
}
token := djwt.NewWithClaims(djwt.SigningMethodRS256, claims)
result, err := token.SignedString(privateKey)
if err != nil {
log.Fatal("TokenSingingError")
}