Go中适当的非对称文件加密
Proper asymmetric file encryption in Go
我需要一种方法来允许多人加密各种文件,但只有一个人能够读取所有文件。我按照各种在线示例用 Go 编写了一个程序,但在某些时候出现了以下错误:
Error from encryption: crypto/rsa: message too long for RSA public key size
RSA 是不是走错了路?如果我将文件分成多个块并加密它们可以吗?有没有我可以轻松使用的非对称分组密码?
我阅读了讨论 here,据说 RSA 不是正确的方法。
能不能也举个例子?
如果您需要 public 对大于密钥大小的数据进行密钥非对称加密,则需要使用混合加密。这就是 HTTPS 的工作原理。
Hybrid encryption is where the data is encrypted with symmetric key encryption such as AES and that key is encrypted with asymmetric key encryption such as RSA or EC (Elliptic Curve) 密码学。
不要将文件分成多个块并加密它们。
所以我最终使用了 GPG,我的服务有一个唯一的私钥,我与我的用户共享 public 一个。
我需要一种方法来允许多人加密各种文件,但只有一个人能够读取所有文件。我按照各种在线示例用 Go 编写了一个程序,但在某些时候出现了以下错误:
Error from encryption: crypto/rsa: message too long for RSA public key size
RSA 是不是走错了路?如果我将文件分成多个块并加密它们可以吗?有没有我可以轻松使用的非对称分组密码?
我阅读了讨论 here,据说 RSA 不是正确的方法。
能不能也举个例子?
如果您需要 public 对大于密钥大小的数据进行密钥非对称加密,则需要使用混合加密。这就是 HTTPS 的工作原理。
Hybrid encryption is where the data is encrypted with symmetric key encryption such as AES and that key is encrypted with asymmetric key encryption such as RSA or EC (Elliptic Curve) 密码学。
不要将文件分成多个块并加密它们。
所以我最终使用了 GPG,我的服务有一个唯一的私钥,我与我的用户共享 public 一个。