https://github.com/jan-bar/encryptionfile
一种安全加密数据的方式,数据可以实现自校验,防止数据损坏和篡改(A way to securely encrypt data, the data can be self-verified to prevent data damage and tampering)
https://github.com/jan-bar/encryptionfile
aes md5 rsa
Last synced: 6 months ago
JSON representation
一种安全加密数据的方式,数据可以实现自校验,防止数据损坏和篡改(A way to securely encrypt data, the data can be self-verified to prevent data damage and tampering)
- Host: GitHub
- URL: https://github.com/jan-bar/encryptionfile
- Owner: jan-bar
- License: apache-2.0
- Created: 2021-03-24T16:35:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-16T13:06:41.000Z (over 2 years ago)
- Last Synced: 2024-06-21T10:11:49.507Z (about 2 years ago)
- Topics: aes, md5, rsa
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 62
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## EncryptionFile
[中文文档](README_CN.md)
for specific usage, please read: [EncryptionFile_test.go](EncryptionFile_test.go)
### implementation
the password is related to the corresponding algorithm
I have this format here: `password = [key + 0 + iv/nonce]`
| rsa ciphertext length | rsa encrypted password data | algorithm encrypted content | hash value |
|-----------------------|-----------------------------|-----------------------------|-------------------------------------------------------------------|
| len(rsa(password)) | rsa(password) | algorithm(content) | hash.Sum(len(rsa(password)) + rsa(password) + algorithm(content)) |
### cipher.AEAD
password composition: `password = [key + 0 + nonce]`
the nonce needs to be taken out correctly, and it must be ensured that there is no 0 in the key
### cipher.Stream
password composition: `password = [key + 0 + iv]`
### cipher.BlockMode
password composition: `password = [key + 0 + iv]`
### example
support encryption schemes in golang standard library: `cipher.AEAD,cipher.Stream,cipher.BlockMode`
at the same time, several encryption schemes of aes are built in: `CFB,CTR,OFB,CBC,GCM`
```go
// an encryption scheme can be specified with the built-in method
// GenEncCipher(cipher.NewCFBEncrypter)
// GenEncCipher(cipher.NewCTR)
// GenEncCipher(cipher.NewOFB)
// GenEncCipher(cipher.NewCBCEncrypter)
// GenEncCipher(cipher.NewGCM)
EncData(Reader, Writer, pubKey, md5.New(), GenEncCipher(cipher.NewCFBEncrypter))
// an decryption scheme can be specified with the built-in method
// GenDecCipher(cipher.NewCFBDecrypter)
// GenDecCipher(cipher.NewCTR)
// GenDecCipher(cipher.NewOFB)
// GenDecCipher(cipher.NewCBCDecrypter)
// GenDecCipher(cipher.NewGCM)
DecData(Reader, Writer, priKey, md5.New(), GenDecCipher(cipher.NewCFBDecrypter))
```
you can also refer to [GenEncCipher](EncryptionFile.go#GenEncCipher) to write the method of generating encryption
you can also refer to [GenDecCipher](EncryptionFile.go#GenDecCipher) to write the method of generating decryption