Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bittorrent/btfs-encryption
https://github.com/bittorrent/btfs-encryption
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/bittorrent/btfs-encryption
- Owner: bittorrent
- License: gpl-3.0
- Created: 2023-01-18T05:41:36.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-01-18T10:29:47.000Z (almost 2 years ago)
- Last Synced: 2024-06-20T05:12:39.566Z (7 months ago)
- Language: Go
- Size: 22.5 KB
- Stars: 2
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BTFS-Encryption
__btfs-encryption__ is a demo project for [BTFS Encrypted Storage Protocol](https://docs.btfs.io/docs/btfs-encrypted-storage-protocol), and provide a binary you can use to encrypt/decrypt files from/to btfs with this protocol:
## How to install
- Use go tools
```shell
go install github.com/bittorrent/btfs-encryption/cmd/btfs-encryption@latest
```
- Build from source: if you have installed __go__ and __make__ tools, you can clone the source code and make:
```shell
git clone [email protected]:bittorrent/btfs-encryption.git && cd btfs-encryption && make
```
the binary will be build as __btfs-encryption__ in the current directory.## Prerequisites
- This project use RSA algorithm to encrypt the secret, so before use the binary, enable the RSA public/private key pairs has been generated in the local.
These key pairs can be generated by below commands:
```shell
ssh-keygen -t rsa
```
Or you can just use the exists key pairs, they are commonly be __$HOME/.ssh/id_rsa__ and __$HOME/.ssh/id_rsa.pub__.
- If you need add encrypted file to BTFS and decrypted file from BTFS, before use these commands, you need set the BTFS_HOST environment variable.
```shell
export BTFS_HOST=
```## Commands
```shell
NAME:
btfs-encryption - btfs-encryption is a demo project for btfs encryption protocolUSAGE:
btfs-encryption [global options] command [command options] [arguments...]VERSION:
v0.1.0COMMANDS:
encrypt Encrypt local file or folder and add it to BTFS
decrypt Get encrypted file from BTFS and decrypt it to local
encrypt-local Encrypt local file or folder
decrypt-local Decrypt local encrypted file
help, h Shows a list of commands or help for one commandGLOBAL OPTIONS:
--help, -h show help (default: false)
--version, -v print the version (default: false)
```
- ### Encrypt local file or folder and add it to BTFS
```shell
./btfs-encryption encrypt [-pub ]
```
If it works, the output will show the encrypted BTFS file info:
```shell
Encrypted File:
CID -
Name -
Size -
```- ### Get encrypted file from BTFS and decrypt it to local
```shell
./btfs-encryption decrypt [-dst ] [-prv ]
```
If it works, the decrypted files will be in the specified destination directory, and output will be:
```shell
completed!
```- ### Encrypt local file or folder
```shell
./btfs-encryption encrypt-local [-dst ] [-pub ]
```
If it works, the encrypted file will be in the specified destination directory, and output will be:
```shell
completed!
```- ### Decrypt local encrypted file
```shell
./btfs-encryption decrypt-local [-src ] [-dst ] [-prv ]
```
If it works, the decrypted files will be in the specified destination directory, and output will be:
```shell
completed!
```## Used as library
The project can be used as library for convenience:
```shell
go get github.com/bittorrent/btfs-encryption
``````go
package mainimport (
"github.com/bittorrent/btfs-encryption/enc"
)func main() {
// encryption
err := enc.EncryptToLocal("path/to/source", "path/to/dest", "path/to/public/key")
if err != nil {
return
}
// decryption
err = enc.DecryptFromLocal("path/to/source", "path/to/dest", "path/to/private/key")
if err != nil {
return
}
}
```