Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error expected key of size 256 bits, but was given 344 bits #28

Closed
abhowmik opened this issue Nov 18, 2020 · 1 comment
Closed

Comments

@abhowmik
Copy link

Hi,
I am trying to implement your code with a shareed key that we are generating through our KMS System.
But I get the below error:
AesGcm.Encrypt(): expected key of size 256 bits, but was given 344 bits.
Here is the code below
func encrypt(){
payload := "ansivadis@xxy.com"
keyBytes := []byte("8EGQNuDdLuiqqcQDrkBOLHcysp0Ans1R1PT5qM5_VP8")

if(keyBytes==nil) {
	panic("invalid key format")
}
//fmt.Println(keyBytes)

token,err := jose.Encrypt(payload, jose.DIR, jose.A256GCM, keyBytes)
fmt.Print(err)
if(err==nil) {
    //go use token
    fmt.Printf("\nDIR A256GCM = %v\n",token)
}

}

func main(){
encrypt()
}

Can you please tell me how to fix this issue with this library?

@abhowmik
Copy link
Author

It is working now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant