/go-shredder

Shred files into chunks, encrypt, decrypt and reassemble

Primary LanguageGoApache License 2.0Apache-2.0

Go-Shredder

Go-Shredder is a package which helps you to split a file, or a byte array into chunks. You wan also encrypt the content with GnuPG or AES encryption.

GoDoc Build Status Go Report Card

Sample usages

Shred a file, reassemble the chunks and print the file content.

    chunks, err := ShredFile("main.go", &Opts{
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }

    content, err := Reassemble(chunks, &Opts{
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }

    fmt.Println(content.String())

With Gnu-PG encryption

Shred a file with GPG encryption. You just need the public key to encrypt.

    chunks, err := ShredFile("main.go", &Opts{
        GPGEncryption: &GPGEncryption{
                PublicKey:  []byte(publicKey),
            },
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }

Reassemble the file; so you need private key and the passphrase.

    content, err := Reassemble(chunks, &Opts{
        GPGEncryption: &GPGEncryption{
            PrivateKey: []byte(privateKey),
            Passphrase: []byte("password"),
        },
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }
    fmt.Println(content.String())

With AES encryption

Shred a file with AES encryption.

    chunks, err := ShredFile("main.go", &Opts{
        AESEncryption:  &AESEncryption{
            key: []byte("a very very very very secret key"), //32 bytes long key
        },
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }

Reassemble the file

    content, err := Reassemble(chunks, &Opts{
        AESEncryption:  &AESEncryption{
            key: []byte("a very very very very secret key"), //32 bytes long key
        },
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }
    fmt.Println(content.String())