{"id":18764714,"url":"https://github.com/celsodias12/base64-from-scratch","last_synced_at":"2026-05-10T02:19:26.347Z","repository":{"id":186618239,"uuid":"675450177","full_name":"celsodias12/base64-from-scratch","owner":"celsodias12","description":"This is a project that provides functions to encode and decode strings or files to base64.","archived":false,"fork":false,"pushed_at":"2023-12-06T01:09:32.000Z","size":742,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-20T20:37:56.043Z","etag":null,"topics":["base64","base64-decoding","base64-encoding","javascript","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/celsodias12.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,"publiccode":null,"codemeta":null}},"created_at":"2023-08-07T00:25:09.000Z","updated_at":"2023-08-15T15:35:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e09ca52-5c58-49e9-b21c-3297b3da567d","html_url":"https://github.com/celsodias12/base64-from-scratch","commit_stats":null,"previous_names":["celsodias12/base64-from-scratch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/celsodias12/base64-from-scratch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celsodias12%2Fbase64-from-scratch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celsodias12%2Fbase64-from-scratch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celsodias12%2Fbase64-from-scratch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celsodias12%2Fbase64-from-scratch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/celsodias12","download_url":"https://codeload.github.com/celsodias12/base64-from-scratch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celsodias12%2Fbase64-from-scratch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265625570,"owners_count":23800624,"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","base64-decoding","base64-encoding","javascript","nodejs"],"created_at":"2024-11-07T18:31:12.880Z","updated_at":"2026-05-10T02:19:21.321Z","avatar_url":"https://github.com/celsodias12.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Text/File to Base64 Converter\n\nThis is a project that provides functions to encode and decode strings or files to base64.\n\n## How to use\n\nTo use the converter, import the `base64` object and call the `encode()` and `decode()` functions as needed.\n\n### Encoding a string to base64\n\nTo encode a string to base64, call the `encode()` function and pass the string as an argument. The function will return a base64-encoded string corresponding to the input.\n\n```typescript\nimport { base64 } from './src'\n\nconst text = 'Hello, world!'\nconst encoded = base64.encode(text)\n\nconsole.log(encoded) // SGVsbG8sIHdvcmxkIQ==\n```\n\n### Decoding a string from base64\n\nTo decode a base64-encoded string, call the `decode()` function and pass the string as an argument. The function will return a text string corresponding to the input.\n\n```typescript\nimport { base64 } from './src'\n\nconst encoded = 'SGVsbG8sIHdvcmxkIQ=='\nconst text = base64.decode(encoded)\n\nconsole.log(text) // Hello, world!\n```\n\n### Encoding a file to base64\n\nTo encode a file to base64, call the `encode()` function and pass a buffer object containing the file as an argument. The function will return a base64-encoded string corresponding to the input.\n\n```typescript\nimport { readFileSync } from 'node:fs'\nimport { base64 } from './src'\n\nconst file = readFileSync('file.txt')\nconst encoded = base64.encode(file)\n\nconsole.log(encoded) // SGVsbG8sIHdvcmxkIQ==\n```\n\n### Decoding a file from base64\n\nTo decode a base64-encoded file, call the `decode()` function and pass the base64-encoded string as an argument. The function will return a buffer object containing the file corresponding to the input.\n\n```typescript\nimport { readFileSync } from 'node:fs'\nimport { base64 } from './src'\n\nconst encoded = 'SGVsbG8sIHdvcmxkIQ=='\nconst file = base64.decode(encoded, true)\n\nwriteFileSync('file.txt', file)\n```\n\n## API\n\n### `base64.encode(text: string | Buffer): string`\n\nEncodes a text string or buffer object to a base64-encoded string.\n\n- `text`: The text string or buffer object to be encoded.\n- `Buffer`: An optional buffer object of the file to be encoded.\n\nReturns a base64-encoded string corresponding to the input.\n\n### `base64.decode(base64: string, isFile = false): string | Buffer`\n\nDecodes a base64-encoded string to a text string or buffer object.\n\n- `base64`: The base64-encoded string to be decoded.\n- `isFile`: An optional boolean value indicating whether the base64-encoded string represents a file.\n\nReturns a text string or buffer object if it is a file corresponding to the input.\n\n## Contributing\n\nIf you want to contribute to the project, feel free to open an issue or send a pull request. All types of contributions are welcome, from bug fixes to new features and performance improvements.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcelsodias12%2Fbase64-from-scratch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcelsodias12%2Fbase64-from-scratch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcelsodias12%2Fbase64-from-scratch/lists"}