Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jkaninda/encryptor
Go Encryptor
https://github.com/jkaninda/encryptor
Last synced: 10 days ago
JSON representation
Go Encryptor
- Host: GitHub
- URL: https://github.com/jkaninda/encryptor
- Owner: jkaninda
- License: mit
- Created: 2024-10-13T04:17:09.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-10-13T13:05:32.000Z (about 1 month ago)
- Last Synced: 2024-10-18T07:55:32.752Z (29 days ago)
- Language: Go
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Encryptor
## Install
```shell
go get github.com/jkaninda/encryptor
```## Encrypt using passphrase
```go
fileBytes, err := os.ReadFile("file.txt")
outputFile :="file.txt.gpg"
if err != nil {
fmt.Printf("Error reading file: %s \n", err)
}
err = encryptor.Encrypt(fileBytes, outputFile, "passphrase")
if err != nil {
panic(err)
}
```## Decrypt using passphrase
```go
fileBytes, err := os.ReadFile("file.txt.gpg")
outputFile :="file.txt"
if err != nil {
fmt.Printf("Error reading file: %s \n", err)
}
err = encryptor.Decrypt(fileBytes, outputFile, "passphrase")
if err != nil {
panic(err)
}
```## Encrypt using GPG public Key
```go
fileBytes, err := os.ReadFile("file.txt")
outputFile := "file.txt.gpg"
if err != nil {
fmt.Printf("Error reading file: %s \n", err)
}
pubKey, err := os.ReadFile("public_key.asc")
if err != nil {
fmt.Printf("Error reading public key: %s ", err)
}
err = encryptor.EncryptWithPublicKey(fileBytes, outputFile, pubKey)
if err != nil {
panic(err)
}
```
## Decrypt using GPG private Key```go
```