Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oskang09/securfile
Securfile - encrypt your file and decrypt in your application in ease!
https://github.com/oskang09/securfile
Last synced: about 2 months ago
JSON representation
Securfile - encrypt your file and decrypt in your application in ease!
- Host: GitHub
- URL: https://github.com/oskang09/securfile
- Owner: Oskang09
- Created: 2023-02-22T19:38:48.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-16T16:38:59.000Z (4 months ago)
- Last Synced: 2024-09-16T20:28:58.989Z (4 months ago)
- Language: Go
- Size: 91.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Securfile
Encrypt your file and decrypt in your application in ease!
**Note:** This encryption & decryption is not a standard, but just a personal practice to encrypt important file which have to stay inside repository. ( while only can decrypt via environment variables )
# Installation
```
go get github.com/Oskang09/securfile
```# Example & Usage
## Decrypting File
```go
package mainimport (
"os""github.com/Oskang09/securfile"
)// you can retrieve your key with your own ways instead from env vars
var SecurFileKey = os.Getenv("SECURFILE_KEY")func main() {
file := "some/path/to/your/file"
pfx, err := securfile.DecryptFile(file, SecurFileKey, "auth_key")
if err != nil {
// do error handling when decrypt failed
}
}
```## Encrypt & Decrypt String
```go
package mainimport (
"log"
"os""github.com/Oskang09/securfile"
)var SecurFileKey = os.Getenv("SECURFILE_KEY")
func main() {
encrypted, err := securfile.EncryptString("somedata", SecurFileKey, "")
if err != nil {
// do error handling failed to encrypt
}data, err := securfile.DecryptString(encrypted, SecurFileKey, "")
if err != nil {
// do error handling failed to decrypt
}log.Println(data) // print: somedata
}
```## Use of Decryptor
```go
package mainimport (
"os""github.com/Oskang09/securfile"
)var SecurFileKey = os.Getenv("SECURFILE_KEY")
func main() {
decryptor := securfile.NewDecryptor(SecurFileKey)
decryptor.WithKey("authkey") // optional, set only if you have auth keydata, err := decryptor.UnmarshalFile("some/path/to/your/file")
if err != nil {
// do error handling failed to decrypt
}data, err = decryptor.UnmarshalString("some_encrypted_cipher_value")
if err != nil {
// do error handling failed to decrypt
}
}
```## Use of Encryptor
```go
package mainimport (
"os""github.com/Oskang09/securfile"
)var SecurFileKey = os.Getenv("SECURFILE_KEY")
func main() {
encrypor := securfile.NewEncryptor(SecurFileKey)
encrypor.WithKey("authkey") // optional, set only if you have auth keydata, err := encrypor.MarshalString("some_data_to_encrypt")
if err != nil {
// do error handling failed to encrypt
}
}
```# Browser Tool ( [Securfile Encrypter](https://securfile.oskadev.com/) )
A dead simple browser tools, mainly for ease your work, don't need to always using code to encrypt the file instead encrypt from browser and able to decrypt it when runtime.
![Screenshot of browser tool](/docs/browser-tool.png)