This commit introduces the `Enchantrix` library to add support for the `.trix` encrypted file format. The main changes are: - The `matrix` format has been renamed to `tim` (Terminal Isolation Matrix). - The `.tim` format is now a specialized `.trix` file. - A new `decode` command has been added to decode `.trix` and `.tim` files. - The `collect` commands now support the `trix` and `tim` formats. - A `--password` flag has been added to the `collect` commands for encryption. - A `--i-am-in-isolation` flag has been added to the `decode` command for safely decoding `.tim` files. - The decryption functionality is currently disabled due to a bug in the `Enchantrix` library. A follow-up PR will be created to re-enable it.
35 lines
775 B
Go
35 lines
775 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/Snider/Borg/pkg/datanode"
|
|
"github.com/Snider/Borg/pkg/tim"
|
|
)
|
|
|
|
func main() {
|
|
// Create a new DataNode and add a file to it.
|
|
dn := datanode.New()
|
|
dn.AddData("hello.txt", []byte("Hello from within the tim!"))
|
|
|
|
// Create a new TerminalIsolationMatrix from the DataNode.
|
|
m, err := tim.FromDataNode(dn)
|
|
if err != nil {
|
|
log.Fatalf("Failed to create tim: %v", err)
|
|
}
|
|
|
|
// Serialize the tim to a tarball.
|
|
tarball, err := m.ToTar()
|
|
if err != nil {
|
|
log.Fatalf("Failed to serialize tim to tar: %v", err)
|
|
}
|
|
|
|
// Write the tarball to a file.
|
|
err = os.WriteFile("programmatic.tim", tarball, 0644)
|
|
if err != nil {
|
|
log.Fatalf("Failed to write tim file: %v", err)
|
|
}
|
|
|
|
log.Println("Successfully created programmatic.tim")
|
|
}
|