{"id":29481034,"url":"https://github.com/4nkitd/cpoch","last_synced_at":"2026-05-08T10:32:33.249Z","repository":{"id":304137960,"uuid":"1016245393","full_name":"4nkitd/cpoch","owner":"4nkitd","description":"numeric string compression","archived":false,"fork":false,"pushed_at":"2025-07-08T18:07:10.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-11T11:55:12.550Z","etag":null,"topics":["c","compression","golang","numeric","php","string"],"latest_commit_sha":null,"homepage":"","language":"C","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/4nkitd.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,"zenodo":null}},"created_at":"2025-07-08T17:53:58.000Z","updated_at":"2025-07-09T17:47:13.000Z","dependencies_parsed_at":"2025-07-11T12:05:23.273Z","dependency_job_id":null,"html_url":"https://github.com/4nkitd/cpoch","commit_stats":null,"previous_names":["4nkitd/cpoch"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/4nkitd/cpoch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4nkitd%2Fcpoch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4nkitd%2Fcpoch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4nkitd%2Fcpoch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4nkitd%2Fcpoch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4nkitd","download_url":"https://codeload.github.com/4nkitd/cpoch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4nkitd%2Fcpoch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265375540,"owners_count":23755255,"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":["c","compression","golang","numeric","php","string"],"created_at":"2025-07-14T23:55:25.664Z","updated_at":"2026-05-08T10:32:28.209Z","avatar_url":"https://github.com/4nkitd.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cpoch Library\n\nCpoch is a numeric string compression algorithm that shortens numeric strings by substituting pairs of digits with single ASCII characters. This repository provides implementations of the Cpoch algorithm in Go, C, and PHP.\n\nThe core idea is to use a predefined map to convert two-digit strings (e.g., \"78\") into a corresponding character (e.g., 'N'). This can reduce the length of long numeric IDs, timestamps, or other numeric data, making them more manageable for display or transmission.\n\n## Implementations\n\nThis project includes the following implementations:\n\n-   **Go**: The core logic is in `cpoch.go`, with tests in `cpoch_test.go`.\n-   **C**: A modular C library located in the `c/` directory, with a `Makefile` for easy compilation and testing.\n-   **PHP**: The core logic is in `cpoch.php`, with a separate test runner in `cpoch_test.php`.\n\n---\n\n## Go Implementation\n\nThe Go implementation is contained within `cpoch.go`. The testing logic has been separated into `cpoch_test.go` according to standard Go practices.\n\n### Usage\n\nTo run the tests, execute the following command in the `cpoch` directory:\n\n```sh\ngo test -v\n```\n\n### API\n\n-   `func EncodeCpoch(dataStr string) string`\n    Encodes a numeric string into its Cpoch representation. If a pair of digits is not found in the encoding map, or for a trailing single digit, the digit is passed through without change.\n\n-   `func DecodeCpoch(data string) string`\n    Decodes a Cpoch string back into its original numeric form. Characters not found in the decoding map are passed through as-is.\n\n---\n\n## C Implementation\n\nThe C implementation has been organized into a library in the `c/` directory. The core logic is in `cpoch.c`, and tests are in the `c/tests/` subdirectory.\n\n### Building and Running Tests\n\nA `Makefile` is provided for convenience. Navigate to the `c/` directory and run the following command:\n\n```sh\ncd c/\nmake test\n```\nThis command will compile the library and the test runner, then execute the test suite.\n\n### API\n\nThe C functions are declared in `cpoch.h`:\n\n-   `char* encode_cpoch(const char* data_str)`\n    Encodes a null-terminated numeric string.\n    **Note**: This function returns a dynamically allocated string that the caller must free using `free()`.\n\n-   `char* decode_cpoch(const char* data)`\n    Decodes a null-terminated Cpoch string.\n    **Note**: This function returns a dynamically allocated string that the caller must free using `free()`.\n\n---\n\n## PHP Implementation\n\nThe PHP implementation is available in `cpoch.php`. The testing logic has been separated into `cpoch_test.php`.\n\n### Testing\n\nTo run the PHP test suite, execute the test script from the command line:\n\n```sh\nphp cpoch_test.php\n```\n\n### Usage\n\nTo use the functions in your own project, include the `cpoch.php` file:\n\n```php\n\u003c?php\n\nrequire_once 'cpoch.php';\n\n$encoded = encodeCpoch(\"783177515862598787\");\n// =\u003e \"Ncye586S98N7\"\n\n$decoded = decodeCpoch(\"Ncye586S98N7\");\n// =\u003e \"783177515862598787\"\n```\n\n### API\n\n-   `function encodeCpoch(string $dataStr): string`\n    Encodes a numeric string into its Cpoch representation.\n\n-   `function decodeCpoch(string $data): string`\n    Decodes a Cpoch string back into its original numeric form.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4nkitd%2Fcpoch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4nkitd%2Fcpoch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4nkitd%2Fcpoch/lists"}