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

建议AesCbcEncrypt支持自定义iv向量 #135

Open
shaoerkuai opened this issue Sep 13, 2023 · 1 comment
Open

建议AesCbcEncrypt支持自定义iv向量 #135

shaoerkuai opened this issue Sep 13, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@shaoerkuai
Copy link

去看了下不同地方的iv算法,发现各有不同,目前采取写法是:
iv := encrypted[:aes.BlockSize]
希望这个能开放自定义

@duke-git
Copy link
Owner

去看了下不同地方的iv算法,发现各有不同,目前采取写法是: iv := encrypted[:aes.BlockSize] 希望这个能开放自定义

需要保持和以前版本兼容,如果开放自定义iv,需要将iv设计成可变参数。可以做如下修改:

func AesCbcEncrypt(data, key []byte, ivs... []byte) {
   iv := encrypted[:aes.BlockSize]

   if len(ivs) > 0 {
     iv = ivs[0]
   }
   // .....
}

@duke-git duke-git added the enhancement New feature or request label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants