dplp5928 2016-10-25 15:24
浏览 1325
已采纳

如何使用RSA加密大文件?

Code https://play.golang.org/p/CUEqjsJq5c

Error:

panic: crypto/rsa: message too long for RSA public key size

goroutine 1 [running]:
panic(0x4a6d80, 0xc420010420)
    /usr/local/go/src/runtime/panic.go:500 +0x1a1
main.main()
    /tmp/sample.go:28 +0xfa

File size 811 byte (for test encrypt self source file). I want encrypt some bigger files, 1..500 mb. Can I do it with RSA or need use some other methods?

  • 写回答

1条回答 默认 最新

  • dongqian8265 2016-10-25 15:51
    关注

    RSA can only encrypt data smaller than the key length.

    The answer is to encrypt the data with a symmetric algorithm such as AES which is designed to encrypt small and large data.

    If an RSA public/private key pair are required encrypt the symmetric (AES) key with RSA. This is referred to as hybrid encryption and in essence is hoe HTTPS encrypts data.

    But it is may not necessary to RSA encrypt the symmetric key unless a public/private key pair are required. In the general case one just uses symmetric (AES) and that key. What is the use case for a public/private key pair?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥30 CanMv K210开发板实现功能
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile