{"id":17383162,"url":"https://github.com/kamaranl/bash64","last_synced_at":"2026-04-30T17:31:28.599Z","repository":{"id":220034449,"uuid":"750044871","full_name":"KamaranL/bash64","owner":"KamaranL","description":"Base64 encoder/decoder for shell scripts","archived":false,"fork":false,"pushed_at":"2024-09-24T11:46:07.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T20:49:38.699Z","etag":null,"topics":["base64","bash","decoder","encoder","minifier","obfuscator","script","shell","shellscript"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KamaranL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-29T22:02:11.000Z","updated_at":"2024-02-06T12:34:22.000Z","dependencies_parsed_at":"2024-10-16T07:40:52.440Z","dependency_job_id":null,"html_url":"https://github.com/KamaranL/bash64","commit_stats":null,"previous_names":["kamaranl/bash64"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KamaranL%2Fbash64","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KamaranL%2Fbash64/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KamaranL%2Fbash64/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KamaranL%2Fbash64/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KamaranL","download_url":"https://codeload.github.com/KamaranL/bash64/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245924498,"owners_count":20694728,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base64","bash","decoder","encoder","minifier","obfuscator","script","shell","shellscript"],"created_at":"2024-10-16T07:40:48.867Z","updated_at":"2026-04-30T17:31:28.568Z","avatar_url":"https://github.com/KamaranL.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"```bash\n    __               __    _____ __ __\n   / /_  ____ ______/ /_  / ___// // /\n  / __ \\/ __ `/ ___/ __ \\/ __ \\/ // /_\n / /_/ / /_/ (__  ) / / / /_/ /__  __/\n/_.___/\\__,_/____/_/ /_/\\____/  /_/\n```\n\n\u003e encode (\u0026 decode) your shell scripts using base64\n\n[![latest release](https://badgen.net/github/release/KamaranL/bash64?icon=github\u0026cache=3600)](https://github.com/KamaranL/bash64/releases/latest)\n\n- [Installation and Usage](#installation-and-usage)\n  - [Dependencies](#dependencies)\n  - [Install](#install)\n    - [Local](#local)\n    - [GitHub Actions](#github-actions)\n  - [Usage](#usage)\n- [Examples](#examples)\n- [Validity](#validity)\n\n## Installation and Usage\n\n### Dependencies\n\n[^1]\n\n- base64\n- bash `\u003e=3`\n- cat\n- date\n- perl `\u003e=5`\n- realpath\n- sha256sum\n\n### Install\n\n#### Local\n\nCopy + paste the following in your terminal to download, unpack, and link the [latest release](https://github.com/KamaranL/bash64/releases/latest):\n\n  ```bash\n  NAME=bash64 VER=\"$(curl -sL \"https://raw.githubusercontent.com/KamaranL/$NAME/main/VERSION.txt\")\" \u0026\u0026 {\n     DIR=\"/usr/local/etc/$NAME.d\"\n     [ ! -d \"$DIR\" ] \u0026\u0026 mkdir -p \"$DIR\"\n     curl -L \"https://github.com/KamaranL/$NAME/releases/download/v$VER/$NAME-v$VER.tgz\" | tar -vxz -C \"$DIR\"\n     chmod +x \"$DIR/$NAME\"\n     [ ! -f \"/usr/local/bin/$NAME\" ] \u0026\u0026 ln -s \"$DIR/$NAME\" \"/usr/local/bin/$NAME\"\n     \"$NAME\" -v \u0026\u0026 \"$NAME\" -h\n  }\n  ```\n\n#### GitHub Actions\n\n  ```yml\n  #...\n  jobs:\n    ci:\n      runs-on: ubuntu-latest\n      steps:\n        - uses: KamaranL/bash64@main\n  #...\n  ```\n\n### Usage\n\n```text\nusage: bash64 [options]\noptions:\n  -e \u003cfile\u003e           encode the specified file\n  -d \u003cfile\u003e           decode the specified file\n  --no-{sha,timestamp,credit,format}\n                      omits the specified option when encoding\n  -h,--help           print this help message\n  -v,--version        print version\n```\n\n## Examples\n\nWe have the following executable script:\n\n\u003csub\u003e***hello.sh***\u003c/sub\u003e\n\n```bash\n#!/usr/bin/env bash\necho Hello \"${1:-World}\"\nexit $?\n```\n\nHow the script is typically executed:\n\n```bash\n$ ./hello.sh\n# Hello World\n\n$ ./hello.sh John\n# Hello John\n```\n\nUsing bash64, we encode the script and redirect the output:\n\n```bash\nbash64 -e hello.sh \u003e/usr/local/bin/hello\n```\n\nMake the script executable:\n\n```bash\nchmod +x /usr/local/bin/hello\n```\n\nTest the newly encoded script:\n\n\u003csub\u003e- since */usr/local/bin* is in our **PATH** we can just call `hello`\u003c/sub\u003e\n\n```bash\n$ hello\n# Hello World\n\n$ hello Mary\n# Hello Mary\n```\n\nIf we check the contents of the encoded script created by bash64, we see:\n\n\u003csub\u003e***/usr/local/bin/hello***\u003c/sub\u003e\n\n```bash\n#!/bin/bash                                                                       1\n# e07db5c63556498c9147f618444619277ddf67d59bbb2dcbedd79329ffcf4315                2\n# 2024-01-30 06:13:18                                                             3\n# encoded with bash64 - https://github.com/KamaranL/bash64                        4\nMAIN='IyEvdXNyL2Jpbi9lbnYgYmFzaAplY2hvIEhlbGxvICIkezE6LVdvcmxkfSIKZXhpdCAkPwo=' # 5\n__MAIN__=\"${0##*\\/}\" \\  #                                                         6\n    /usr/bin/env bash \u003c(base64 -d \u003c\u003c\u003c\"$MAIN\") \"$@\" #                              7\nexit $? #                                                                         8\n```\n\n*Line-by-line analysis:*\n\n1. the shebang `#!`.\n1. the SHA256 checksum of the *raw* source file contents.\n1. the date and time the encoding occurred of the source file.\n1. the credit line that contains the name of the encoding script and its GitHub repository.\n1. **MAIN** stores a base64 encoded string that contains the contents of the source file.\n1. **\\_\\_MAIN__** [^2] contains the name of the encoded script, and is defined immediately before executing the encoded string so that it can be passed to the context that the encoded string will run in.\n1. a continuation of the previous line, because of the `\\`. Here you will see the path to the interpreter that was provided in the first line of the source file, which is then taking in the base64 encoded string and then decoding it upon execution, while passing along all positional parameters.\n1. exits with the exit code of the previous line (where the base64 encoded string is being executed[^3]):.\n\n## Validity\n\nEveryone has doubts, see [my wiki page](https://github.com/KamaranL/KamaranL/wiki#validation) on validation if you're like everyone :smile:\n\n[^1]: Most, if not all, of the listed dependencies come pre-installed on MacOS and a good number of Linux distributions- provided for transparency.\n\n[^2]: This is implemented because after encoding the source file, the `$0` parameter, as well as the `$BASH_SOURCE` variable, in shell scripts do not decode correctly from standard input upon execution. For example, if we encoded the following source file:\n\n    ```bash\n    #!/bin/bash\n    echo The name of this script is \"$__MAIN__\"\n    exit 0\n    ```\n\n    and the name of the encoded script was ***whatami***, we would expect the following:\n\n    ```bash\n    $ whatami\n    # The name of this script is whatami\n    ```\n\n    Automatic formatting is already in place to substitute `$0` and `$BASH_SOURCE` for `$__MAIN__`, but if you would prefer to change these variables yourself, you can use the `--no-format` option and bash64 will print the lines that need remediation prior to encoding.\n\n[^3]: It's worth noting that *without* an exit code in the source file, the script *may* return false exit codes of 1 when executed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamaranl%2Fbash64","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamaranl%2Fbash64","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamaranl%2Fbash64/lists"}