timwhitez starred EncryptionFile
2023-8-28 15:33:19 Author: github.com(查看原文) 阅读量:24 收藏

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

1 branch 2 tags

Code

Latest commit

Files

Permalink

Failed to load latest commit information.

Type

Name

Latest commit message

Commit time

EncryptionFile

加密解密文件
由于需要使用流式加解密因此选用AES CFB模式
使用RSA将随机密钥加密,并将密文存入文件头部
加密文件只需要提供程序和公钥
解密文件只需要提供程序和私钥
相同文件每次加密结果都不一样,安全系数极高
可以指定计算hash算法,最终会在末尾存入hash值

加密后数据内容如下,随机生成key, iv,不用私钥解密谁也不知道这两个的值

为了让加解密都使用io.Reader和io.Writer,将hash放在末尾,读取文件需要正确处理尾部hash

rsa密文长度 rsa加密aes密码后的密文 aes加密内容 数据hash值
len(rsa(key + iv)) rsa(key + iv) aes(data) hash(len(rsa(key + iv)) + rsa(key + iv) + aes(data))

文章来源: https://github.com/jan-bar/EncryptionFile
如有侵权请联系:admin#unsafe.sh