{"id":16370208,"url":"https://github.com/mrdcvlsc/bytepadding","last_synced_at":"2025-07-18T08:36:18.415Z","repository":{"id":181377844,"uuid":"666664045","full_name":"mrdcvlsc/BytePadding","owner":"mrdcvlsc","description":"A collection of different byte padding methods","archived":false,"fork":false,"pushed_at":"2023-07-17T04:12:16.000Z","size":484,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-31T22:52:36.789Z","etag":null,"topics":["alignment","ansix923","block","block-cipher","block-cipher-mode","byte-array","c-plus-plus","cplusplus","cpp","cryptography","data-processing","data-stream","fill","iso-iec-7810","library","memory","memory-management","padding","pkcs5","pkcs7"],"latest_commit_sha":null,"homepage":"","language":"C++","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/mrdcvlsc.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}},"created_at":"2023-07-15T06:48:56.000Z","updated_at":"2023-11-17T00:57:47.000Z","dependencies_parsed_at":"2024-01-14T16:13:06.177Z","dependency_job_id":"7cfd1d47-260e-42c7-8f72-83c01dcf3692","html_url":"https://github.com/mrdcvlsc/BytePadding","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"5a874d1a80d3f68a02f52cfc96bc26b3d1042d24"},"previous_names":["mrdcvlsc/bytepadding"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mrdcvlsc/BytePadding","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdcvlsc%2FBytePadding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdcvlsc%2FBytePadding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdcvlsc%2FBytePadding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdcvlsc%2FBytePadding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrdcvlsc","download_url":"https://codeload.github.com/mrdcvlsc/BytePadding/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdcvlsc%2FBytePadding/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265728943,"owners_count":23818733,"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":["alignment","ansix923","block","block-cipher","block-cipher-mode","byte-array","c-plus-plus","cplusplus","cpp","cryptography","data-processing","data-stream","fill","iso-iec-7810","library","memory","memory-management","padding","pkcs5","pkcs7"],"created_at":"2024-10-11T03:04:21.957Z","updated_at":"2025-07-18T08:36:18.393Z","avatar_url":"https://github.com/mrdcvlsc.png","language":"C++","readme":"# BytePadding - A collection of different byte padding methods\n\n![tests](https://github.com/mrdcvlsc/BytePadding/actions/workflows/tests.yml/badge.svg)\n\nBytePadding is a small and simple repository that offers a collection of various byte padding methods.\n\nByte padding is a technique used to add additional bytes to a data stream, typically at the end, to ensure the data meets specific alignment requirements or fits a particular format.\n\n-----------\n\n## **Requirements**\n\n- Requires C++17 so you need to compile it with the compilation flag `-std=c++17`.\n\n## **Currently Available Padding Headers**\n\n```c++\n#include \"padding/ANSI_X9_23.hpp\"\n#include \"padding/PKCS_5_7.hpp\"\n#include \"padding/ISO_IEC_7816_4.hpp\"\n```\n\n## **Sample program:**\n\n```c++\n/*    sample.cpp    */\n#include \u003ciostream\u003e\n#include \"padding/PKCS_5_7.hpp\"\n\nusing namespace Padding;\n\nint main()\n{\n    size_t padding_block = 8;\n\n    unsigned char data1[] = { 0xfd, 0xfd, 0xfd, };\n\n    unsigned char data2[] = {\n      0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd,\n    };\n\n    unsigned char data3[] = {\n      0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd,\n    };\n\n    ByteArray pad1 = PKCS_5_7::Add(subject1, sizeof(subject1), padding_block);\n    ByteArray old1 = PKCS_5_7::Remove(pad1.data(), pad1.size());\n\n    ByteArray pad2 = PKCS_5_7::Add(subject2, sizeof(subject2), padding_block);\n    ByteArray old2 = PKCS_5_7::Remove(pad2.data(), pad2.size());\n\n    ByteArray pad3 = PKCS_5_7::Add(subject3, sizeof(subject3), padding_block);\n    ByteArray old3 = PKCS_5_7::Remove(pad3.data(), pad3.size());\n}\n```\n\n**Encrypted Value:**\n\n```c++\n// data 1 padded result\n0xfd, 0xfd, 0xfd, 0x05, 0x05, 0x05, 0x05, 0x05,\n\n// data 2 padded result\n0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0x01,\n\n// data 3 padded result\n0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd,\n0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,\n```\n\n**Byte Array Holder Class**\n\nThe `Padding::ByteArray` class is used to hold the result of the padding function and it offeres a small amount of method to handle different operations, and a destructor to automatically free the array after going out of scope.\n\nIf you want to **read** the array of a `Padding::ByteArray` object instance you can call the `ByteArray.data()` method, this method will return a `const unsigned char *` containing the array values.\n\nIf you want to manage the **Raw C style array** yourself, you can use the `ByteArray.size()` method to get the size of the array, then `ByteArray.detach()` method to get the `unsigned char *` pointer of the array, **this will detach the pointer inside the `ByteArray` so you will need to dellocate the detached pointer yourself!** `free()`/`delete []`.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdcvlsc%2Fbytepadding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrdcvlsc%2Fbytepadding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdcvlsc%2Fbytepadding/lists"}