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

是否有必要每次连接都生成新的cipher? #22

Open
fankeke opened this issue Oct 29, 2017 · 2 comments
Open

是否有必要每次连接都生成新的cipher? #22

fankeke opened this issue Oct 29, 2017 · 2 comments

Comments

@fankeke
Copy link

fankeke commented Oct 29, 2017

hello,您好:
cipher := NewCipher(t.crypotMethod, t.secret)

这句在每次连接时都会有新的cipher,但每次都生成有必要吗?
全程都应该是同样的加密方法,用一个cipher是不是就可以了,这样也减少开销。

谢谢。

@ghoulr
Copy link
Member

ghoulr commented Oct 30, 2017

当时这么做可能是担心出现cipher会随着加密进程出现变化吧,你可以改下测试试试全局唯一的cipher是否可以正常加解密

@fankeke
Copy link
Author

fankeke commented Oct 30, 2017

hello:
我试了下,如果用全局的cipher来做,只有在请求并发很低的情况下才能正常加解密work。
但在高并发下是不行的。

我估计是用了io.copy这样的函数,在协程间共用了buffer。(我猜的,可能也不对)

但我还是觉得cipher应该全局唯一才好,因为他只做了加解密而已,并不用正对每一对上下游生成。
全程的加解密算法都是一样的。

不是很明白这里了。请教~

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

2 participants