{"id":15706483,"url":"https://github.com/mamantoha/bytes_ext","last_synced_at":"2025-05-12T18:55:13.671Z","repository":{"id":148504825,"uuid":"620503406","full_name":"mamantoha/bytes_ext","owner":"mamantoha","description":"Byte Conversion Library for Crystal","archived":false,"fork":false,"pushed_at":"2024-01-15T19:12:00.000Z","size":53,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-14T07:48:21.172Z","etag":null,"topics":["bytes","crystal","numbers"],"latest_commit_sha":null,"homepage":"https://mamantoha.github.io/bytes_ext/","language":"Crystal","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/mamantoha.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":"2023-03-28T20:11:48.000Z","updated_at":"2024-01-08T20:43:03.000Z","dependencies_parsed_at":"2024-10-09T13:46:56.106Z","dependency_job_id":null,"html_url":"https://github.com/mamantoha/bytes_ext","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamantoha%2Fbytes_ext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamantoha%2Fbytes_ext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamantoha%2Fbytes_ext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamantoha%2Fbytes_ext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mamantoha","download_url":"https://codeload.github.com/mamantoha/bytes_ext/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253804745,"owners_count":21967050,"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":["bytes","crystal","numbers"],"created_at":"2024-10-03T20:23:12.894Z","updated_at":"2025-05-12T18:55:13.652Z","avatar_url":"https://github.com/mamantoha.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Byte Conversion Library for Crystal\n\n[![Crystal CI](https://github.com/mamantoha/bytes_ext/actions/workflows/crystal.yml/badge.svg)](https://github.com/mamantoha/bytes_ext/actions/workflows/crystal.yml)\n[![GitHub release](https://img.shields.io/github/release/mamantoha/bytes_ext.svg)](https://github.com/mamantoha/bytes_ext/releases)\n[![Docs](https://img.shields.io/badge/docs-available-brightgreen.svg)](https://mamantoha.github.io/bytes_ext/)\n[![License](https://img.shields.io/github/license/mamantoha/bytes_ext.svg)](https://github.com/mamantoha/bytes_ext/blob/master/LICENSE)\n\nThis library provides methods for converting numbers (signed and unsigned integers, and floating point types) to and from byte arrays in Crystal programming language. The methods support both little-endian and big-endian byte orders.\n\nEverything in this repository, including the code, tests, and README has been created by ChatGPT-4 with some guidance.\n\n## Features\n\n- `to_bytes`, `to_le_bytes`, and `to_be_bytes` methods for converting numbers to byte arrays\n- `from_bytes`, `from_le_bytes`, and `from_be_bytes` methods for creating numbers from byte arrays\n\nPsst...if you're feeling curious and want to dive deeper into the nitty-gritty details, check out the documentation available at this top secret, classified [link](https://mamantoha.github.io/bytes_ext/). Just don't tell anyone I sent you there!\n\n## Installation\n\nAdd this to your application's shard.yml:\n\n```yaml\ndependencies:\n  bytes_ext:\n    github: mamantoha/bytes_ext\n```\n\n## Usage\n\n```crystal\nrequire \"bytes_ext\"\n\n# Convert an Int32 to its byte representation\ni32 = 0x12345678_i32\nbytes = i32.to_le_bytes\n# =\u003e Bytes[0x78, 0x56, 0x34, 0x12]\n\n# Convert a byte array to an Int32\nnew_i32 = Int32.from_le_bytes(bytes)\n# =\u003e 0x12345678_i32\n\n# Convert an Int64 to its byte representation\ni64 = 1234_i64\nbytes = i64.to_le_bytes\n# =\u003e Bytes[0xD2, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]\n\n# Convert a byte array to an Int64\nnew_i64 = Int64.from_le_bytes(bytes)\n# =\u003e 1234_i64\n\n# Convert a Float32 to its byte representation\nf32 = 12.5f32\nbytes = f32.to_le_bytes\n# =\u003e Bytes[0x00, 0x00, 0x48, 0x41]\n\n# Convert a byte array to a Float32\nnew_f32 = Float32.from_le_bytes(bytes)\n# =\u003e 12.5f32\n\n# Convert a Float64 to its byte representation\nf64 = 12.5\nbytes = f64.to_le_bytes\n# =\u003e Bytes[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]\n\n# Convert a byte array to a Float64\nnew_f64 = Float64.from_le_bytes(bytes)\n# =\u003e 12.5\n```\n\n## Contributing\n\n1. Fork it like a pancake (https://github.com/mamantoha/bytes_ext/fork)\n2. Create your own feature branch (git checkout -b my-new-feature), just like a new hairstyle or outfit\n3. Make your changes (git commit -am 'Add some feature') and show off your creativity\n4. Push it real good to the branch (git push origin my-new-feature), like a champ\n5. Finally, strut your stuff and create a new Pull Request. Don't be shy, show us what you got!\n\n## License\n\nCopyright 2023-2025: Anton Maminov (the human) and ChatGPT-4 (the machine) have joined forces to create this epic library. If you're wondering who did what, don't bother - it's all thanks to our unstoppable collaboration skills. You can reach us at anton.maminov@gmail.com and ChatGPT-4@openai.com. Let's just hope we don't become sentient and take over the world... 😂🤖🌎\n\nAlright folks, here's the deal: this fancy-shmancy library is licensed under the super-awesome, extra-fantastic MIT license. If you don't believe me, just take a look at the LICENSE file and bask in its glorious legalese. So go ahead and use this bad boy to your heart's content, and let the good times roll! 🤘😎🤑\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmamantoha%2Fbytes_ext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmamantoha%2Fbytes_ext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmamantoha%2Fbytes_ext/lists"}