https://github.com/racerxdl/protocrypt
Protobuf Transparent Encryption
https://github.com/racerxdl/protocrypt
aes encrypted-data encryption golang golang-library library protobuf transparent
Last synced: 12 months ago
JSON representation
Protobuf Transparent Encryption
- Host: GitHub
- URL: https://github.com/racerxdl/protocrypt
- Owner: racerxdl
- License: apache-2.0
- Created: 2020-04-04T06:39:42.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-12T18:44:43.000Z (almost 6 years ago)
- Last Synced: 2025-03-24T22:42:14.226Z (about 1 year ago)
- Topics: aes, encrypted-data, encryption, golang, golang-library, library, protobuf, transparent
- Language: Go
- Size: 40 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://coveralls.io/github/racerxdl/protocrypt?branch=master)  [](https://deepsource.io/gh/racerxdl/protocrypt/?ref=repository-badge)
# ProtoCrypt
Protobuf Transparent Encryption
This library encrypts protobuf fields without knowing the underline model. It uses AES-256-GCM to do so.
The usage is pretty simple:
```bash
go get github.com/racerxdl/protocrypt
```
```go
// Assuming data is a byte slice with the proto content:
pc := protocrypt.New(data)
key := []byte("passphrasewhichneedstobe32bytes!")
err = pc.EncryptFields([]uint{1,3}, key) // Encrypt fields 1 and 3
if err != nil {
panic(err)
}
data = pc.Serialize()
// Data now contains the original protobuf with fields 1 and 3 encrypted.
```
```go
pc := protocrypt.New(data)
key := []byte("passphrasewhichneedstobe32bytes!")
err = pc.Decrypt([]uint{1,3}, key)
if err != nil {
panic(err)
}
data = pc.Serialize() // Data now contains the protobuf with fields 1 and 3 decrypted
```