{"id":21984425,"url":"https://github.com/alesiong/codec","last_synced_at":"2025-03-23T01:44:30.135Z","repository":{"id":98349926,"uuid":"223681759","full_name":"alesiong/codec","owner":"alesiong","description":"A Swiss Army knife for en/de- coding/crypting strings","archived":false,"fork":false,"pushed_at":"2023-02-23T02:33:48.000Z","size":62,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T05:12:20.045Z","etag":null,"topics":["crypto","encryption","golang","swissarmyknife","utility"],"latest_commit_sha":null,"homepage":"","language":"Go","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/alesiong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2019-11-24T02:27:51.000Z","updated_at":"2021-08-22T02:25:10.000Z","dependencies_parsed_at":"2023-05-17T12:31:22.801Z","dependency_job_id":null,"html_url":"https://github.com/alesiong/codec","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesiong%2Fcodec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesiong%2Fcodec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesiong%2Fcodec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesiong%2Fcodec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alesiong","download_url":"https://codeload.github.com/alesiong/codec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245044493,"owners_count":20551898,"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":["crypto","encryption","golang","swissarmyknife","utility"],"created_at":"2024-11-29T18:09:29.380Z","updated_at":"2025-03-23T01:44:30.112Z","avatar_url":"https://github.com/alesiong.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# codec\nA Swiss Army knife for en/de- coding/crypting strings\n\n## Description\n`codec` will read string from `stdin`, transform it through multiple en/de-coders\nand print the result to `stdout`\n\n## Usage\n```\ncodec options codecs\n\noptions:\n    -e (default): set the global coding mode to encode\n    -d: set the global coding mode to decode\n    -n: append new line ('\\n') at the end of output (= append `newline` after)\n    -I string: use `string` as input instead of stdin (= insert `const -C` before)\n    -F file: use content of `file` as input instead of stdin (= insert `cat -c -F` before)\n    -O file: use `file` as output instead of stdout (= append `tee -O` after)\n\ncodecs:\n    a list of codecs(en/de-coders), input will be passed and transformed from\n    left to right\n\ncodec:\n    codec-name codec-options\n\ncodec-options:\n    lower case options are switch(boolean) options, so they take no argument.\n\n    upper case options take one argument. the argument can be provided with plain\n    string or by sub-codecs syntax: [plain-string codecs]. If you use sub-codecs\n    syntax, the codecs inside [] will be run on `plain-string` as input, and the\n    output is used as the argument.\n```\n\n### Examples\nYou can use `echo -n '' | ` to pass the input string directly.\n```\ncodec -d base64 zlib\n```\nDecode base64 on input, and then decompress with zlib.\n\n```\ncodec aes-ecb -K [12345678901234561234567890123456 hex -d] base64\n```\nDecode hex string `12345678901234561234567890123456`, and set it as aes-ecb key.\nEncrypt the input, and then encode with base64. Note that unlike `openssl`, aes\ncodecs do not expect hex string as key. You always pass a raw byte string as key.\n\n### Available Codecs and Options\nIf `-d` or `-e` is passed as a codec option, it will overwrite the global coding\nmode.\n\n```\nurl\n    url query escape/unescape\n    -p: use path escape instead of query escape\n\nbase64\n    -u: use url base64 instead\n\naes-ecb\n    -K key\n\naes-cbc\n    -K key\n    -IV iv\n\nhex\n    binary to hex encode or inverse\n    -c: use capital hex string (only affects encoding)\n\nsha256\n\nmd5\n\nzlib\n    -L level: compress level (int, [-2, 9], default -1)\n\nid\n    pass input to output as is\n\nconst\n    -C replacement: ingore input, and replace the output with `replacement`\n\nrepeat\n    -T times: repeat input for `times` times (int, \u003e=0, default 0)\n\ntee\n    (if with no argument, behave like `id`)\n    -c: (close output) do not write to output\n    -O file: also write to `file`, optional\n\nredirect\n    = tee -c -O `file`\n    -O file: redirect output to `file`\n\nsink\n    (= tee -c or redirect -O /dev/null on unix-like systems)\n    differences with repeat: repeat without arguments (=repeat -T 0) will end the\n    execution of the whole chain immediately, e.g.:\n    const -C example tee -O /dev/stdout sink\n        will output example\n    const -C example tee -O /dev/stdout repeat\n        will output nothing\n\nappend\n    -A string: pass input to output, and then append `string`\n\nnewline\n    (= append -A ['\\n' escape -d])\n    append new line\n\nescape\n    escape/unescape with Go string escaping sequences\n\ncat\n    (if with no argument, behave like `id`)\n    -c: (close input) do not read from input\n    -F file: also read from `file`, optional\n\ndrop\n    -B count: drop at most first `count` bytes from input\n\ntake\n    -B count: take up to first `count` bytes from input\n```\n\n# TODO\n1. refactor code\n2. load codecs as go plugins\n3. usage\n4. codec aliases/scripts (implement it as super-meta codec)\n5. if codecs","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falesiong%2Fcodec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falesiong%2Fcodec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falesiong%2Fcodec/lists"}