Base64 Encode/Decode multiple files.
-
create
.b64f
file under working directory with list of files that should be encoded to base64 file. Each entry support glob pattern, for example:pkg/util/testdata/* **/*.yml
-
run the following command to encode the listed files. This will create a new sibling file for each listed file with additional
.b64
extension, e.g.pkg/util/testdata/a.key
will producepkg/util/testdata/a.key.b64
. Note that it will overwride the.b64
file if it already existed.go run -mod=mod github.com/telkomindonesia/b64f encode
-
to decode back the
.b64
files, run the following command on the same directory. Note that it will overwride the decoded file if it already existed.go run -mod=mod github.com/telkomindonesia/b64f decode
Instead of using go run
you can download pre-compiled binary from Github releases page.
Another alternative is to use docker, e.g.
docker run --rm \
-v "$PWD:$PWD" -w "$PWD" \
ghcr.io/telkomindonesia/b64f:latest \
[decode|encode]
You can use makefie
to make the command simpler, for example:
b64f: mode ?= "decode"
b64f:
go run -mod=mod github.com/telkomindonesia/b64f $(mode)
which can then be used using make b64f
or make b64f mode=encode
see testdata folder for example.