{"id":16735674,"url":"https://github.com/sequencemedia/crypto","last_synced_at":"2026-05-22T14:07:31.138Z","repository":{"id":63776670,"uuid":"570659438","full_name":"sequencemedia/crypto","owner":"sequencemedia","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-26T04:37:35.000Z","size":1433,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-03-26T21:08:15.802Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sequencemedia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2022-11-25T18:39:38.000Z","updated_at":"2024-03-28T05:32:25.397Z","dependencies_parsed_at":"2024-03-28T05:32:14.910Z","dependency_job_id":"a3b32060-226b-4a79-95f9-aedb23e860a4","html_url":"https://github.com/sequencemedia/crypto","commit_stats":{"total_commits":246,"total_committers":1,"mean_commits":246.0,"dds":0.0,"last_synced_commit":"af55f393eaec1e3bf8bac82361095525722fb749"},"previous_names":[],"tags_count":402,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequencemedia%2Fcrypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequencemedia%2Fcrypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequencemedia%2Fcrypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequencemedia%2Fcrypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sequencemedia","download_url":"https://codeload.github.com/sequencemedia/crypto/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243521210,"owners_count":20304187,"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":[],"created_at":"2024-10-13T00:06:52.908Z","updated_at":"2026-05-22T14:07:26.096Z","avatar_url":"https://github.com/sequencemedia.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @sequencemedia/crypto\n\nEncrypt and decrypt in Node and Bash\n\n## Node\n\nThe package _main_ exports two functions, `encrypt` and `decrypt`\n\n```javascript\nimport {\n  encrypt,\n  decrypt\n} from '@sequencemedia/crypto'\n```\n\n### `encrypt`\n\n```typescript\nfunction encrypt(\n  buffer: Buffer,\n  secret: string,\n  bytes?: number,\n  algorithm?: string\n): Buffer\n```\n\nOnly `buffer` and `secret` are _required_\n\n- `buffer` is the data to encrypt\n- `secret` is the secret key to use for encryption\n\nBoth `bytes` and `algorithm` are _optional_\n\n- `bytes` is the number of random bytes to use for the encryption _initialisation vector_. The default is `16`\n- `algorithm` is the algorithm to use for encryption. The default is `aes-256-ctr`\n\n### `decrypt`\n\n```typescript\nfunction decrypt(\n  buffer: Buffer,\n  secret: string,\n  bytes?: number,\n  algorithm?: string\n): Buffer\n```\n\nOnly `buffer` and `secret` are _required_\n\n- `buffer` is the data to decrypt\n- `secret` is the secret key to use for decryption\n\nBoth `bytes` and `algorithm` are _optional_\n\n- `bytes` is the number of bytes to slice from the buffer for the decryption _initialisation vector_. The default is `16`\n- `algorithm` is the algorithm to use for decryption. The default is `aes-256-ctr`\n\n## Bash\n\nThe package contains three scripts\n\n1. `crypto.sh`\n1. `encrypt.sh`\n2. `decrypt.sh`\n\nScript `crypto.sh` exports four functions to consume in your own Bash scripts\n\n```bash\nsource ./crypto.sh\n```\n\n1. `encrypt`\n2. `decrypt`\n3. `encrypt_directory`\n4. `decrypt_directory`\n\nScripts [`encrypt.sh`](#encryptsh) and [`decrypt.sh`](#decryptsh) can be executed at the command line\n\n### Bash functions\n\n#### `encrypt`\n\nRequires `CRYPTO_KEY` as a _variable_ in the Bash environment and a file path to _encrypt_\n\n```bash\nCRYPTO_KEY='secret'\nencrypted_file_data=$(encrypt \"./file.txt\")\n```\n\n```bash\nCRYPTO_KEY='secret'\nencrypt \"./file.txt\" \u003e \"./encrypted.txt\"\n```\n\n#### `decrypt`\n\nRequires `CRYPTO_KEY` as a _variable_ in the Bash environment and a file path to _decrypt_\n\n```bash\nCRYPTO_KEY='secret'\nfile_data=$(decrypt \"./encrypted.txt\")\n```\n\n```bash\nCRYPTO_KEY='secret'\ndecrypt \"./encrypted.txt\" \u003e \"./file.txt\"\n```\n\n#### `encrypt_directory`\n\nRequires `CRYPTO_KEY` as a _variable_ in the Bash environment and a directory path to _encrypt_\n\n- The first argument is the origin directory of files to _encrypt_\n- The second argument is the destination directory for the _encrypted_ files\n\n```bash\nCRYPTO_KEY='secret'\nencrypt_directory \"./directory\" \"./encrypted\"\n```\n\n#### `decrypt_directory`\n\nRequires `CRYPTO_KEY` as a _variable_ in the Bash environment and a directory path to _decrypt_\n\n- The first argument is the origin directory of files to _decrypt_\n- The second argument is the destination directory for the _decrypted_ files\n\n```bash\nCRYPTO_KEY='secret'\ndecrypt_directory \"./encrypted\" \"./directory\"\n```\n\n### Bash scripts\n\n#### `encrypt.sh`\n\nRequires `CRYPTO_KEY` as a _variable_ in the Bash environment\n\n- You can provide either _file_ or _directory_ paths\n- You can provide `--verbose` or `-v`\n\n##### File paths\n\n- A file _origin_ path to _encrypt_\n- A file _destination_ path for the _encrypted_ file\n\n```bash\nCRYPTO_KEY='secret' ./encrypt.sh \\\n  --origin \"./file.txt\" \\\n  --destination \"./encrypted.txt\"\n```\n\n##### Directory paths\n\n- A directory _origin_ path to _encrypt_\n- A directory _destination_ path for _encrypted_ files\n\n```bash\nCRYPTO_KEY='secret' ./encrypt.sh \\\n  --origin \"./directory\" \\\n  --destination \"./encrypted\"\n```\n\n#### `decrypt.sh`\n\nRequires `CRYPTO_KEY` as a _variable_ in the Bash environment\n\n- You can provide either _file_ or _directory_ paths\n- You can provide `--verbose` or `-v`\n\n##### File paths\n\n- A file _origin_ path to _decrypt_\n- A file _destination_ path for the _decrypted_ file\n\n```bash\nCRYPTO_KEY='secret' ./decrypt.sh \\\n  --origin \"./encrypted.txt\" \\\n  --destination \"./file.txt\"\n```\n\n##### Directory paths\n\n- A directory _origin_ path to _decrypt_\n- A directory _destination_ path for _decrypted_ files\n\n```bash\nCRYPTO_KEY='secret' ./decrypt.sh \\\n  --origin \"./encrypted\" \\\n  --destination \"./directory\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsequencemedia%2Fcrypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsequencemedia%2Fcrypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsequencemedia%2Fcrypto/lists"}