Packaging and encrypting/decrypting your files for Golang

🔑 Paket – A vault to packaging and encrypt/decrypt your files in golang!

pkg.go.dev | Go Report Card

Table of Contents

🔊 Informations

Hey,
this is not for archiving your files like 7-zip.

We recommend that you take a look at the items below before using this module.
The world of encryption and encryption is a complex topic. It is important to know what you are doing and what this module actually does.

  • Is it really secure? How secure is it?

Frankly the person who wants to get the data can crack anything if he or she tries. Especially if the program you are distributing runs directly on the user's computer and all data is with the program. However, what AES and Package do is complex enough.
Don't Remember, every executable file is sensitive to disassembly.
You can pass your files through other complex processes before encrypting them. However, this causes your program to load files into memory slowly at run time.

  • What encryption algorithm does it use?

AES CFB.
If enough people write to add new algorithms, we will add new algorithms to the extent that golang supports it.

👩‍🏭 👨‍🏭 What does it do?

Imagine you are producing a game. You will probably have carefully designed animations and sound effects. You do not want users to receive this data.
If we think for this scenario; The package encrypts the files in the specified folder using AES with a key you specify. And it combines all encrypted files into a single file. Calculates the hash of the encrypted and unencrypted version of the file. Saves to a table. This is a little shield for people trying to deceive you.
Then, you can easily retrieve the decoded or encrypted version of your file from the encrypted file.
Normally you should create a system to securely encrypt and decrypt your files.
This is a ready system 😎 .

🏎 Installation

This module consists of two parts:

  1. CMD tool – command-line tool for encrypting and packaging files.
  2. "pengine" (paket engine) – subfolder that provides low-level APIs (reading encrypted datas, verifications etc...).

To use Paket, you need to create a package file with the cmd tool.

You can install it like a normal golang module:
go get -u github.com/SeanTolstoyevski/paket

Usage of CMD Tool

Let's run the -help command of the Paket to see if it has been installed successfully:

cmd>paket -help
Usage of paket.exe:
  -f string
        Folder containing files to be encrypted.
        It is not recursive, Subfolders is not encrypted.
  -k string
        Key for encrypting files. It must be 16, 24 or 32 length in bytes.
        If this parameter is null, the tool generates one randomly byte  and prints value to the console.
  -o string
        The file to which your encrypted data will be written.
         If there is a file with the same name, you will be warned. (default "data.pack")
  -s    prints progress steps to the console. For example, which file is currently encrypting, etc. (default true)
  -t string
        The go file to be written for Paket to read.
         When compiling this file, you must import it into your program.
         It is created as "package main." (default "PaketTable.go")

Warning: If the key is null, the system randomly generates a key.

Create a package file with cmd tool

You can create a package with something like:

paket -f=mydatas -o=data.dat

Example output:

❗❕ Warning! Your random key. Please note: 092f8e0b25b0eeea32037e716dfcf2bc
3 files were found in mydatas folder.
Comedy of Errors (complete text) - Shakespeare.txt file is encrypting. Size: 0.9117 MB
George Orwell - Animal Farm.pdf file is encrypting. Size: 5.5276 MB
openal_soft_readme.md file is encrypting. Size: 0.0288 MB

If you don't want the details, you can pass -s=0 parameter.
so:
paket -f=mydatas -o=data.dat -s=0

Next, a go file like this is created.
This is the table that keeps the information of your files.

The generated go code would look like this.

//important: You can edit this file. However, you need to know what you are doing.
// *panic* may occur.

package main

import (
	paket "github.com/SeanTolstoyevski/paket/pengine"
)

//The map vault for datas. The init function writing the required data.
var Data = make(paket.Datas)

// The name of the folder from which the files were was taken. Information is writing by init.
var foldername string

func init() {
	foldername = "datas"
	Data["Comedy of Errors (complete text) - Shakespeare.txt"] = paket.Values{"0", "91189", "91173", "91189", "2aa62dd2d930ed5d8e1c3a33fba4d8525e16448b12d567f5808452b94cacf693", "063b28be3d49e30710546c06b845e87ef9af811f01f7ef716be1f4516657d2d3"}
	Data["George Orwell - Animal Farm.pdf"] = paket.Values{"91189", "643961", "552756", "552772", "2d8d5810046a78daea56adcf73497b6f331023a0a2cb700db4bb029ca1425573", "86a5e5508ce4f8912f6f62b7c06c51134beb86722fa6ba670751ce727c3e081f"}
	Data["openal_soft_readme.md"] = paket.Values{"643961", "646858", "2881", "2897", "4034ec4242e7a700e2586f6520941599230e7bc8509ca60950e570df213c49ae", "0f16e1d5e7bbc82b1cb067190db8abc6aa8f00507395710095cc5cd45deb4d2a"}
}

Great, we created our first package. We're going to write some code now.

Examples

If you want you can examine the codes in the examples folder.

😋 If you like this

  • 📝 🖊 Please consider creating a PR or emailing me for grammatical errors and other language issues in documents. English is not my native language.

  • If you can test for Linux and Darwin, that would be a great for me. I am a blind software developer. I cannot set up an environment in Linux that can develop and test these projects. Linux's accessibility is not as good as Windows. No mac. I'll try to test as much as possible with the built-in go test though.

  • 💰 🤑 If you don't want to do any of them and want to give financial support (like a cup of french press), you can send an e-mail

  • 🌟 And send a star. This is the greatest favor. I'm looking for a job. Employers are not so optimistic in Turkey against disabled users. But any good project with a few stars can win over employers' hearts.

🤔 FAQ

  • Why name Paket?

Package in English, "paket" in Turkish.
I was looking for a module where I could package my data. This name came first to mind.

  • Which Go versions are compatible?

Tested with Go 15.3 64 bit on windows 10 64 bit.
Probably compatible up to go1.12-13.

Owner
👨‍🦯 I coding often Golang.
null
Similar Resources

Build apps that run everywhere with Go and a browser engine of your choice (Chrome, Firefox, Epiphany or Android WebView).

hydrapp Build apps that run everywhere with Go and a browser engine of your choice (Chrome, Firefox, Epiphany or Android WebView). Overview 🚧 This pr

Dec 14, 2022

Sign, verify, encrypt and decrypt data with GPG in your browser.

Sign, verify, encrypt and decrypt data with GPG in your browser.

keygaen Sign, verify, encrypt and decrypt data with GPG in your browser. ⚠️ keygaen has not yet been audited! While we try to make keygaen as secure a

Nov 22, 2022

List your dependencies capabilities and monitor if updates require more capabilities.

A take on supply chain security in Go List your dependencies capabilities and monitor if dependency updates require more capabilities. The Problem Rec

Nov 16, 2022

CLI Tool to remove unwanted connections from your Chia Node based on Geo IP Location.

chia-bouncer Tiny CLI tool to remove unwanted connections from your Chia Node based on the Geo IP Location (Country). The Tool is written in golang an

Jun 25, 2021

Tool for monitoring your Ethereum clients. Client-agnostic as it queries the standardized JSON-RPC APIs

Tool for monitoring your Ethereum clients. Client-agnostic as it queries the standardized JSON-RPC APIs

e7mon Tool for monitoring your Ethereum clients. Client-agnostic as it queries the standardized JSON-RPC APIs. However, the execution client should be

Dec 20, 2022

A blockcypher exporter to monitor your blockchain nodes to Prometheus.

A blockcypher exporter to monitor your blockchain nodes to Prometheus. Metrics are retrieved using the BlockCypher REST API.

Nov 2, 2021

A russian roulette-like programme that has a 1/6 chance to delete your OS.

russianRouletteGo russianRouletteGo - a russian roulette-like programme that has a 1/6 chance to delete your OS. Last tested and built in Go 1.17.3 Us

Jan 3, 2022

Build your own blockchain!

Build your own blockchain!

Build your own Blockchain in Javascript With all the hype about blockchains and cryptocurrencies, I decided to learn a bit more about it. And what bet

Dec 31, 2022

Boxen - put your network operating systems in a box!

boxen boxen -- put your network operating systems in a box (or if you speak 🇩🇪 , fight them! 🤣 )! boxen is a cli tool written in Go that allows you

Nov 26, 2022
Command Line Tool for decrypting armored pgp messages

Decrypt-PGP-Message A simple command line tool for decrypting armored pgp messages How to build? make build How to use? Usage: -key=<path to your pr

Nov 4, 2021
sops is an editor of encrypted files that supports YAML, JSON, ENV, INI and BINARY formats and encrypts with AWS KMS, GCP KMS, Azure Key Vault, age, and PGP
sops is an editor of encrypted files that supports YAML, JSON, ENV, INI and BINARY formats and encrypts with AWS KMS, GCP KMS, Azure Key Vault, age, and PGP

sops is an editor of encrypted files that supports YAML, JSON, ENV, INI and BINARY formats and encrypts with AWS KMS, GCP KMS, Azure Key Vault, age, and PGP. (demo)

Jan 9, 2023
Script in Golang using Go 1.6 std lib methods to traverse directories and read the files

dev-check-in Script in Golang using Go 1.6 std lib methods to traverse directories and read the files Using only the standard library. It will find al

Dec 14, 2021
A dead simple tool to sign files and verify digital signatures.

minisign minisign is a dead simple tool to sign files and verify signatures. $ minisign -G

Dec 16, 2022
Cross-platform application for easy encrypted sharing of files, folders, and text between devices.
Cross-platform application for easy encrypted sharing of files, folders, and text between devices.

wormhole-gui Wormhole-gui is a cross-platform application that lets you easily share files, folders and text between devices. It uses the Go implement

Dec 30, 2022
ThanosDecryptor is an project to decrypt files encrypted by Thanos ransomware.

Prometheus-Decryptor Prometheus-Decryptor is an project to decrypt files encrypted by Prometheus ransomware. Command Arguments Usage of ./bin/promethe

Dec 16, 2022
Sidecar container for injecting secrets into configuration files from Hashicorp Vault

talebearer noun A person who spreads scandal or tells secrets; gossip Note This code is not being actively developed, and has not seen substantial cha

Nov 1, 2021
Uses Google's classic diff-match-patch algorithm to compare two files, sending the color highlighted output to *testing.T for use when testing expected versus actual results.

Compare-files uses Google's classic diff-match-patch algorithm to compare two files. It sends the color highlighted output to *testing.T for use when

Dec 30, 2021
HLF smart-bft WAL files reader

WAL Reader Utility for reading Hyperledger Fabric SmartBFT WAL files. Install go install gitlab.n-t.io/atmz/walreader@latest Read WAL file walreader

Jan 14, 2022
Split and distribute your private keys securely amongst untrusted network
Split and distribute your private keys securely amongst untrusted network

cocert An experimental tool for splitting and distributing your private keys safely* cocert, generates ECDSA - P521 key and uses a technique known as

Dec 5, 2022