{"id":16115116,"url":"https://github.com/naomijub/brcode","last_synced_at":"2025-05-08T00:34:57.505Z","repository":{"id":47624285,"uuid":"294517070","full_name":"naomijub/brcode","owner":"naomijub","description":"PIX BR Code Parser for Rust","archived":false,"fork":false,"pushed_at":"2024-02-23T17:00:16.000Z","size":26257,"stargazers_count":63,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-01T15:47:15.686Z","etag":null,"topics":["brcode","pix"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/brcode","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/naomijub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":null,"patreon":"naomijub","custom":["https://github.com/sponsors/naomijub","https://patreon.com/naomijub"]}},"created_at":"2020-09-10T20:36:36.000Z","updated_at":"2023-07-27T20:19:40.000Z","dependencies_parsed_at":"2024-09-18T21:10:29.739Z","dependency_job_id":null,"html_url":"https://github.com/naomijub/brcode","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naomijub%2Fbrcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naomijub%2Fbrcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naomijub%2Fbrcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naomijub%2Fbrcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naomijub","download_url":"https://codeload.github.com/naomijub/brcode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225022974,"owners_count":17408744,"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":["brcode","pix"],"created_at":"2024-10-09T20:17:26.370Z","updated_at":"2024-11-18T00:06:51.584Z","avatar_url":"https://github.com/naomijub.png","language":"Rust","readme":"# BR Code\n[![codecov](https://codecov.io/gh/naomijub/brcode/branch/master/graph/badge.svg?token=1DEONNFLTX)](https://codecov.io/gh/naomijub/brcode)\n\nA crate to parse and emit [PIX BR Code](https://www.bcb.gov.br/content/estabilidadefinanceira/spb_docs/ManualBRCode.pdf).\n* [Technical and Business specs for BR Code usage](https://www.bcb.gov.br/content/estabilidadefinanceira/forumpireunioes/Anexo%20I%20-%20QRCodes%20-%20Especifica%C3%A7%C3%A3o%20-%20vers%C3%A3o%201-1.pdf)\n\n## Important Changes\n\n* Version `1.2` has a small break for a `BrCode` field. [PR](https://github.com/naomijub/brcode/pull/14) fixes `model::BrCode` field `initiation_method` naming.\n\n## Usage\n\n```toml\n[dependencies]\nbrcode = \"1.4.2\"\n```\n\n### Build from source\n1. Install [rustup](https://rustup.rs/).\n2. `make build-macos` for macos and ios files or `make build-linux` for linux and android files.\n3. Files will be located at `target/release/libbrcode.*`, `target/\u003ctarget-platform\u003e/release/libbrcode.so`.\n4. Copy them to the root of your project.\n5. For JVM it is important to run `export LD_LIBRARY_PATH=.` at the root of the project\n\n### Copy files from Github Release\nShellscript to get files from release:\n\n**So**\n```sh\ncurl -s https://api.github.com/repos/naomijub/brcode/releases/latest \\\n| grep \"browser_download_url.*so\" \\\n| cut -d : -f 2,3 \\\n| tr -d \\\" \\\n| wget -qi -\n```\n\n**dylib**\n```sh\ncurl -s https://api.github.com/repos/naomijub/brcode/releases/latest \\\n| grep \"browser_download_url.*dylib\" \\\n| cut -d : -f 2,3 \\\n| tr -d \\\" \\\n| wget -qi -\n```\n\n## Example\n\n**Parse String**\n```rust\nuse brcode::{from_str, Data};\n\nfn main() {\n    let code = \"00020104141234567890123426580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-42665544000027300012BR.COM.OUTRO011001234567895204000053039865406123.455802BR5917NOME DO RECEBEDOR6008BRASILIA61087007490062190515RP12345678-201980390012BR.COM.OUTRO01190123.ABCD.3456.WXYZ6304AD38\";\n\n    assert_eq!(from_str(code), expected());\n}\n\nfn expected() -\u003e Vec\u003c(usize, Data)\u003e {\n    vec![\n        (0, Data::Single(\"01\".to_string())), \n        (4, Data::Single(\"12345678901234\".to_string())), \n        (26, Data::Vector(vec![\n            (0, Data::Single(\"BR.GOV.BCB.PIX\".to_string())), \n            (1, Data::Single(\"123e4567-e12b-12d1-a456-426655440000\".to_string()))])), \n        (27, Data::Vector(vec![\n            (0, Data::Single(\"BR.COM.OUTRO\".to_string())), \n            (1, Data::Single(\"0123456789\".to_string()))])), \n        (52, Data::Single(\"0000\".to_string())), \n        (53, Data::Single(\"986\".to_string())), \n        (54, Data::Single(\"123.45\".to_string())), \n        (58, Data::Single(\"BR\".to_string())), \n        (59, Data::Single(\"NOME DO RECEBEDOR\".to_string())), \n        (60, Data::Single(\"BRASILIA\".to_string())), \n        (61, Data::Single(\"70074900\".to_string())), \n        (62, Data::Vector(vec![\n            (5, Data::Single(\"RP12345678-2019\".to_string()))])), \n        (80, Data::Vector(vec![(\n            0, Data::Single(\"BR.COM.OUTRO\".to_string())), \n            (1, Data::Single(\"0123.ABCD.3456.WXYZ\".to_string()))])), \n        (63, Data::Single(\"AD38\".to_string()))]\n}\n```\n\n**str_to_brcode**\n```rust\nuse brcode::{str_to_brcode, BrCode, Template, Info, MerchantInfo, Label};\n\n\nfn main() {\n    let code = \"00020104141234567890123426580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-42665544000027300012BR.COM.OUTRO011001234567895204000053039865406123.455802BR5917NOME DO RECEBEDOR6008BRASILIA61087007490062190515RP12345678-201980390012BR.COM.OUTRO01190123.ABCD.3456.WXYZ6304AD38\";\n\n    assert_eq!(from_str(code), expected());\n}\n\nfn expected() -\u003e BrCode {\n    BrCode {\n        payload_version: 1,\n        initiation_method: None,\n        merchant_category_code: 0000u32,\n        merchant_name: \"NOME DO RECEBEDOR\".to_string(),\n        merchant_city: \"BRASILIA\".to_string(),\n        merchant_information: vec![\n            MerchantInfo {\n                id: 26,\n                info: vec![\n                    Info {\n                        id: 0,\n                        info: \"BR.GOV.BCB.PIX\".to_string(),\n                    },\n                    Info {\n                        id: 1,\n                        info: \"123e4567-e12b-12d1-a456-426655440000\".to_string(),\n                    },\n                ],\n            },\n            MerchantInfo {\n                id: 27,\n                info: vec![\n                    Info {\n                        id: 0,\n                        info: \"BR.COM.OUTRO\".to_string(),\n                    },\n                    Info {\n                        id: 1,\n                        info: \"0123456789\".to_string(),\n                    },\n                ],\n            },\n        ],\n        currency: \"986\".to_string(),\n        postal_code: Some(\"70074900\".to_string()),\n        amount: Some(123.45),\n        country_code: \"BR\".to_string(),\n        field_template: vec![Label {\n            reference_label: \"RP12345678-2019\".to_string(),\n        }],\n        crc1610: \"AD38\".to_string(),\n        templates: Some(vec![Template {\n            id: 80usize,\n            info: vec![\n                Info {\n                    id: 0usize,\n                    info: \"BR.COM.OUTRO\".to_string(),\n                },\n                Info {\n                    id: 1usize,\n                    info: \"0123.ABCD.3456.WXYZ\".to_string(),\n                },\n            ],\n        }]),\n    }\n}\n```\n\n**brcode::to_string** from `Vec\u003c(usize, Data)\u003e`:\n```rust\nuse brcode::{\n    self, BrCode, \n};\n\nfn main() {\n    let actual = brcode::to_string(brcode_vec());\n    let code = \"00020104141234567890123426580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-42665544000027300012BR.COM.OUTRO011001234567895204000053039865406123.455802BR5917NOME DO RECEBEDOR6008BRASILIA61087007490062190515RP12345678-201980390012BR.COM.OUTRO01190123.ABCD.3456.WXYZ6304AD38\";\n\n    assert_eq!(actual, code);\n}\n\nfn brcode_vec() -\u003e Vec\u003c(usize, Data)\u003e {\n    vec![\n        (0, Data::Single(\"01\".to_string())),\n        (4, Data::Single(\"12345678901234\".to_string())),\n        (\n            26,\n            Data::Vector(vec![\n                (0, Data::Single(\"BR.GOV.BCB.PIX\".to_string())),\n                (\n                    1,\n                    Data::Single(\"123e4567-e12b-12d1-a456-426655440000\".to_string()),\n                ),\n            ]),\n        ),\n        (\n            27,\n            Data::Vector(vec![\n                (0, Data::Single(\"BR.COM.OUTRO\".to_string())),\n                (1, Data::Single(\"0123456789\".to_string())),\n            ]),\n        ),\n        (52, Data::Single(\"0000\".to_string())),\n        (53, Data::Single(\"986\".to_string())),\n        (54, Data::Single(\"123.45\".to_string())),\n        (58, Data::Single(\"BR\".to_string())),\n        (59, Data::Single(\"NOME DO RECEBEDOR\".to_string())),\n        (60, Data::Single(\"BRASILIA\".to_string())),\n        (61, Data::Single(\"70074900\".to_string())),\n        (\n            62,\n            Data::Vector(vec![(5, Data::Single(\"RP12345678-2019\".to_string()))]),\n        ),\n        (\n            80,\n            Data::Vector(vec![\n                (0, Data::Single(\"BR.COM.OUTRO\".to_string())),\n                (1, Data::Single(\"0123.ABCD.3456.WXYZ\".to_string())),\n            ]),\n        ),\n        (63, Data::Single(\"AD38\".to_string())),\n    ]\n}\n\n```\n\n**brcode::brcode_to_string** for struct `BrCode`:\n```rust\nuse brcode::{\n    self, BrCode, \n};\n\nfn main() {\n    let actual = brcode::brcode_to_string(brcode_value());\n    let code = \"00020104141234567890123426580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-42665544000027300012BR.COM.OUTRO011001234567895204000053039865406123.455802BR5917NOME DO RECEBEDOR6008BRASILIA61087007490062190515RP12345678-201980390012BR.COM.OUTRO01190123.ABCD.3456.WXYZ6304AD38\";\n\n    assert_eq!(actual, code);\n}\n\nfn brcode_value() -\u003e BrCode {\n    BrCode {\n        payload_version: 1,\n        initiation_method: None,\n        merchant_account_information: Some(String::from(\"12345678901234\")),\n        merchant_category_code: 0000u32,\n        merchant_name: \"NOME DO RECEBEDOR\".to_string(),\n        merchant_city: \"BRASILIA\".to_string(),\n        merchant_information: vec![\n            MerchantInfo {\n                id: 26,\n                info: vec![\n                    Info {\n                        id: 0,\n                        info: \"BR.GOV.BCB.PIX\".to_string(),\n                    },\n                    Info {\n                        id: 1,\n                        info: \"123e4567-e12b-12d1-a456-426655440000\".to_string(),\n                    },\n                ],\n            },\n            MerchantInfo {\n                id: 27,\n                info: vec![\n                    Info {\n                        id: 0,\n                        info: \"BR.COM.OUTRO\".to_string(),\n                    },\n                    Info {\n                        id: 1,\n                        info: \"0123456789\".to_string(),\n                    },\n                ],\n            },\n        ],\n        currency: \"986\".to_string(),\n        postal_code: Some(\"70074900\".to_string()),\n        amount: Some(123.45),\n        country_code: \"BR\".to_string(),\n        field_template: vec![Label {\n            reference_label: \"RP12345678-2019\".to_string(),\n        }],\n        crc1610: \"AD38\".to_string(),\n        templates: Some(vec![Template {\n            id: 80usize,\n            info: vec![\n                Info {\n                    id: 0usize,\n                    info: \"BR.COM.OUTRO\".to_string(),\n                },\n                Info {\n                    id: 1usize,\n                    info: \"0123.ABCD.3456.WXYZ\".to_string(),\n                },\n            ],\n        }]),\n    }\n}\n```\n\n### **`BrCode` functions** context related\n* `pub fn is_pix(\u0026self) -\u003e bool` determines if BrCode is a `PIX` transaction.\n* `pub fn get_transaction_id(\u0026self) -\u003e Option\u003cString\u003e` gets `transaction_id` value (field 5 of item 65).\n* `pub fn get_alias(\u0026self) -\u003e Option\u003cVec\u003cString\u003e\u003e` gets all possible values for PIX aliases. Usually only field 1 of item 26 is valid. Checks if the alias if of type `\"BR.GOV.BCB.PIX\"`.\n* `pub fn get_message(\u0026self) -\u003e Option\u003cVec\u003cString\u003e\u003e` gets all possible massages for PIX aliases. Usually only field 2 of item 26 is valid. Checks if the alias if of type `\"BR.GOV.BCB.PIX\"`.\n\n### **`BrCode` functions** QrCode generation related:\n* `to_svg_string(\u0026self, ecc: QrCodeEcc, size: usize) -\u003e String` generates a SVG xml in a String.\n* `to_svg_standard_string(\u0026self) -\u003e String` generates a SVG xml in a String with `QrCodeEcc::Low` and `size = 1024`.\n* `to_vec_u8(\u0026self, ecc: QrCodeEcc, size: usize) -\u003e Vec\u003cu8\u003e` generates a PNG formatted in `Vec\u003cu8\u003e`.\n* `to_svg_file(\u0026self, file_path: \u0026str, ecc: QrCodeEcc, size: usize)` creates a QR Code in format `.svg` located at file path `file_path`.\n* `to_standard_svg_file(\u0026self, file_path: \u0026str)` creates a QR Code in format `.svg` located at file path `file_path` with `QrCodeEcc::Low` and `size = 1024`.\n* `to_png_file(\u0026self, file_path: \u0026str, ecc: QrCodeEcc, size: usize)` creates a QR Code in format `.png` located at file path `file_path`.\n\n* `file_path` examples are `tests/data/file_output.png` and `tests/data/file_output.svg` from the project root. If directory doesn't exist an error will be thrown. \n* `QrCodeEcc` is the error correction level in a QR Code symbol and `size` is the image size.\n    * `QrCodeEcc::Low` The QR Code can tolerate about 7% erroneous codewords.\n    * `QrCodeEcc::Medium` The QR Code can tolerate about 15% erroneous codewords.\n    * `QrCodeEcc::Quartile` The QR Code can tolerate about 25% erroneous codewords.\n    * `QrCodeEcc::High` The QR Code can tolerate about 30% erroneous codewords.\n\n## Benchmark\n\n**from_str** in `benches/parse.rs`\n```\ntime:   [15.734 us 15.758 us 15.782 us]\n```\n\n**str_to_brcode** in `benches/to_brcode`\n```\ntime:   [24.886 us 24.931 us 24.977 us]\n```\n\n**edn_from_brcode** in `benches/to_brcode`\n```\ntime:   [52.670 us 52.795 us 52.929 us]\n```\n\n**json_from_brcode** in `benches/to_brcode`\n```\ntime:    [28.229 us 28.284 us 28.339 us]\n```\n\n**both-ways using `BrCode`**\n```\ntime:   [33.238 us 33.555 us 33.924 us]                          \n```\n\n**both-ways using `Vec\u003c(usize, Data)\u003e`**\n```\ntime:   [22.867 us 22.958 us 23.107 us]\n```\n\n**crc16_ccitt** in `benches/crc16`:\n```\ntime:   [3.0738 us 3.0825 us 3.0938 us]\n```\n\n## FFI\n\n### Clojure FFI \n[DOCS](https://github.com/naomijub/brcode/blob/master/clj-brcode/README.md)\n\n**BR Code as Edn** call function FFI `edn_from_brcode` or use clojar `[clj-brcode \"1.1.0-SNAPSHOT\"]`. Example:\n```clojure\n(ns example.core\n  (:require [clj-brcode.core :refer :all]))\n\n(def code \"00020104141234567890123426580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-42665544000027300012BR.COM.OUTRO011001234567895204000053039865406123.455802BR5917NOME DO RECEBEDOR6008BRASILIA61087007490062190515RP12345678-201980390012BR.COM.OUTRO01190123.ABCD.3456.WXYZ6304AD38\")\n\n(brcode-\u003eedn code)\n\n; {:payload-version 1, :initiation-method nil, :merchant-information [{:id 26, :info [{:id 0, :info \"BR.GOV.BCB.PIX\"}, {:id 1, :info \"123e4567-e12b-12d1-a456-426655440000\"}]}, {:id 27, :info [{:id 0, :info \"BR.COM.OUTRO\"}, {:id 1, :info \"0123456789\"}]}], :merchant-category-code 0, :merchant-name \"NOME DO RECEBEDOR\", :merchant-city \"BRASILIA\", :postal-code \"70074900\", :currency \"986\", :amount 123.45, :country-code \"BR\", :field-template [{:reference-label \"RP12345678-2019\"}], :crc1610 \"AD38\", :templates [{:id 80, :info [{:id 0, :info \"BR.COM.OUTRO\"}, {:id 1, :info \"0123.ABCD.3456.WXYZ\"}]}]}\n```\n\nInput:\n```rust\n\"00020104141234567890123426580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-42665544000027300012BR.COM.OUTRO011001234567895204000053039865406123.455802BR5917NOME DO RECEBEDOR6008BRASILIA61087007490062190515RP12345678-201980390012BR.COM.OUTRO01190123.ABCD.3456.WXYZ6304AD38\"\n```\n\nExpected Edn:\n```clojure\n{:payload-version 1,:initiation-method nil, :merchant-information [\n  {:id 26, :info [{ :id 0, :info \"BR.GOV.BCB.PIX\",}, {:id 1, :info \"123e4567-e12b-12d1-a456-426655440000\",}]},\n  {:id 27, :info [{ :id 0, :info \"BR.COM.OUTRO\",}, {:id 1, :info \"0123456789\",}]}\n ],:merchant-category-code 0, :merchant-name \"NOME DO RECEBEDOR\", :merchant-city \"BRASILIA\", \n :postal-code \"70074900\", :currency \"986\", :amount 123.45, :country-code \"BR\", \n :field-template [{ :reference-label \"RP12345678-2019\", }], :crc1610 \"AD38\", :templates [\n   { :id 80, :info [{ :id 0, :info \"BR.COM.OUTRO\", },{ :id 1, :info \"0123.ABCD.3456.WXYZ\", }], }]\n }\n```\n\n\n**Edn as BR Code** call function FFI `edn_to_brcode` or use clojar `[clj-brcode \"1.1.0-SNAPSHOT\"]`. Example:\n```clojure\n(ns example.core\n  (:require [clj-brcode.core :refer :all]))\n\n(def edn {:payload-version 1, :initiation-method nil, :merchant-information [{:id 26, :info [{:id 0, :info \"BR.GOV.BCB.PIX\"}, {:id 1, :info \"123e4567-e12b-12d1-a456-426655440000\"}]}, {:id 27, :info [{:id 0, :info \"BR.COM.OUTRO\"}, {:id 1, :info \"0123456789\"}]}], :merchant-category-code 0, :merchant-name \"NOME DO RECEBEDOR\", :merchant-city \"BRASILIA\", :postal-code \"70074900\", :currency \"986\", :amount 123.45, :country-code \"BR\", :field-template [{:reference-label \"RP12345678-2019\"}], :crc1610 \"AD38\", :templates [{:id 80, :info [{:id 0, :info \"BR.COM.OUTRO\"}, {:id 1, :info \"0123.ABCD.3456.WXYZ\"}]}]})\n\n(brcode-\u003eedn edn)\n\n; \"00020104141234567890123426580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-42665544000027300012BR.COM.OUTRO011001234567895204000053039865406123.455802BR5917NOME DO RECEBEDOR6008BRASILIA61087007490062190515RP12345678-201980390012BR.COM.OUTRO01190123.ABCD.3456.WXYZ6304AD38\"\n```\n\n**Other available functions**:\n- `json-\u003ebrcode`\n- `brcode-\u003ejson`\n- `crc16-ccitt`\n\n### Clojure Benchmark with Criterium\n\n**brcode-\u003eedn**\n```\nEvaluation count : 4644 in 6 samples of 774 calls.\n             Execution time mean : 131.416626 µs\n    Execution time std-deviation : 2.218919 µs\n   Execution time lower quantile : 130.073353 µs ( 2.5%)\n   Execution time upper quantile : 135.212868 µs (97.5%)\n                   Overhead used : 8.079635 ns\n```\n\n**edn-\u003ebrcode**\n```\nEvaluation count : 3816 in 6 samples of 636 calls.\n             Execution time mean : 157.407924 µs\n    Execution time std-deviation : 3.556917 µs\n   Execution time lower quantile : 154.338082 µs ( 2.5%)\n   Execution time upper quantile : 162.800564 µs (97.5%)\n                   Overhead used : 8.102766 ns\n```\n\n**(-\u003e brcode brcode-\u003eedn edn-\u003ebrcode)**\n```\nEvaluation count : 1920 in 6 samples of 320 calls.\n             Execution time mean : 344.903181 µs\n    Execution time std-deviation : 26.518055 µs\n   Execution time lower quantile : 328.923528 µs ( 2.5%)\n   Execution time upper quantile : 390.059255 µs (97.5%)\n                   Overhead used : 8.071450 ns\n```\n\n### Node FFI \n[neon-brcode](https://github.com/naomijub/neon-brcode)\n\n### Dart FFI\n[DOCS](https://github.com/naomijub/brcode/blob/master/dartbrcode/README.md)\n\n**Parse**\n```dart\nimport 'package:dartbrcode/dartbrcode.dart';\n\nfinal json = '{\"payload_version\":1,\"initiation_method\":null,\"merchant_account_information\":\"12345678901234\",\"merchant_information\":[{\"id\":26,\"info\":[{\"id\":0,\"info\":\"BR.GOV.BCB.PIX\"},{\"id\":1,\"info\":\"123e4567-e12b-12d1-a456-426655440000\"}]},{\"id\":27,\"info\":[{\"id\":0,\"info\":\"BR.COM.OUTRO\"},{\"id\":1,\"info\":\"0123456789\"}]}],\"merchant_category_code\":0,\"merchant_name\":\"NOME DO RECEBEDOR\",\"merchant_city\":\"BRASILIA\",\"postal_code\":\"70074900\",\"currency\":\"986\",\"amount\":123.45,\"country_code\":\"BR\",\"field_template\":[{\"reference_label\":\"RP12345678-2019\"}],\"crc1610\":\"AD38\",\"templates\":[{\"id\":80,\"info\":[{\"id\":0,\"info\":\"BR.COM.OUTRO\"},{\"id\":1,\"info\":\"0123.ABCD.3456.WXYZ\"}]}]}';\n\nvoid main() {\n  jsonToBrcode(json);\n  // '00020104141234567890123426580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-42665544000027300012BR.COM.OUTRO011001234567895204000053039865406123.455802BR5917NOME DO RECEBEDOR6008BRASILIA61087007490062190515RP12345678-201980390012BR.COM.OUTRO01190123.ABCD.3456.WXYZ6304AD38'\n}\n```\n\n**Emit**\n```dart\nimport 'package:dartbrcode/dartbrcode.dart';\n\nfinal brcode = '00020104141234567890123426580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-42665544000027300012BR.COM.OUTRO011001234567895204000053039865406123.455802BR5917NOME DO RECEBEDOR6008BRASILIA61087007490062190515RP12345678-201980390012BR.COM.OUTRO01190123.ABCD.3456.WXYZ6304AD38';\n\nvoid main() {\n  jsonFromBrcode(brcode);\n  // '{\"payload_version\":1,\"initiation_method\":null,\"merchant_account_information\":\"12345678901234\",\"merchant_information\":[{\"id\":26,\"info\":[{\"id\":0,\"info\":\"BR.GOV.BCB.PIX\"},{\"id\":1,\"info\":\"123e4567-e12b-12d1-a456-426655440000\"}]},{\"id\":27,\"info\":[{\"id\":0,\"info\":\"BR.COM.OUTRO\"},{\"id\":1,\"info\":\"0123456789\"}]}],\"merchant_category_code\":0,\"merchant_name\":\"NOME DO RECEBEDOR\",\"merchant_city\":\"BRASILIA\",\"postal_code\":\"70074900\",\"currency\":\"986\",\"amount\":123.45,\"country_code\":\"BR\",\"field_template\":[{\"reference_label\":\"RP12345678-2019\"}],\"crc1610\":\"AD38\",\"templates\":[{\"id\":80,\"info\":[{\"id\":0,\"info\":\"BR.COM.OUTRO\"},{\"id\":1,\"info\":\"0123.ABCD.3456.WXYZ\"}]}]}'\n}\n```\n\n**Other available functions**:\n- `crc16Ccitt`\n\n### Benchmarks\n\n* with `dart_benchmark`\n**jsonToBrcode**\n```\nFor 100 runs: peak: 371 us,\tbottom: 048 us,\tavg: ~083 us\n```\n\n**brcodeToJson**\n```\nFor 100 runs: peak: 327 us,\tbottom: 069 us,\tavg: ~101 us\n```\n\n* with `benchmark_harness`\n**jsonToBrcode**\n```\nFor 10 runs: 207.51774227018055 us.\n```\n\n**brcodeToJson**\n```\nFor 10 runs: 378.68780764861793 us.\n```\n\n## Goals\n- [x] Parse BR Code String to  `Vec\u003c(usize, Data)\u003e` (more flexible solution);\n- [x] Parse BR Code to `BrCode` struct;\n- [x] Emit BR Code from `Vec\u003c(usize, Data)\u003e`;\n- [x] Emit BR Code from `BrCode` struct;\n- [x] CRC16_CCITT\n- [x] FFI \n","funding_links":["https://patreon.com/naomijub","https://github.com/sponsors/naomijub"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaomijub%2Fbrcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaomijub%2Fbrcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaomijub%2Fbrcode/lists"}