{"id":13544903,"url":"https://github.com/moov-io/iso8583","last_synced_at":"2025-05-16T14:08:07.411Z","repository":{"id":37265979,"uuid":"271368248","full_name":"moov-io/iso8583","owner":"moov-io","description":"A golang implementation to marshal and unmarshal iso8583 message.","archived":false,"fork":false,"pushed_at":"2025-05-05T23:56:50.000Z","size":1393,"stargazers_count":421,"open_issues_count":13,"forks_count":123,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-05-06T00:37:33.611Z","etag":null,"topics":["card-processing","credit-card","debit-card","hacktoberfest","iso8583"],"latest_commit_sha":null,"homepage":"https://moov.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moov-io.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-06-10T19:35:02.000Z","updated_at":"2025-04-30T01:45:12.000Z","dependencies_parsed_at":"2023-10-05T03:45:24.320Z","dependency_job_id":"7596fef4-7179-460a-a169-a18b872f2957","html_url":"https://github.com/moov-io/iso8583","commit_stats":null,"previous_names":[],"tags_count":86,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moov-io%2Fiso8583","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moov-io%2Fiso8583/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moov-io%2Fiso8583/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moov-io%2Fiso8583/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moov-io","download_url":"https://codeload.github.com/moov-io/iso8583/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544146,"owners_count":22088807,"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":["card-processing","credit-card","debit-card","hacktoberfest","iso8583"],"created_at":"2024-08-01T11:00:54.790Z","updated_at":"2025-05-16T14:08:05.700Z","avatar_url":"https://github.com/moov-io.png","language":"Go","funding_links":[],"categories":["Banking Infrastructure"],"sub_categories":[],"readme":"[![Moov Banner Logo](https://user-images.githubusercontent.com/20115216/104214617-885b3c80-53ec-11eb-8ce0-9fc745fb5bfc.png)](https://github.com/moov-io)\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/moov-io/iso8583/tree/master/docs\"\u003eProject Documentation\u003c/a\u003e\n  ·\n  \u003ca href=\"https://slack.moov.io/\"\u003eCommunity\u003c/a\u003e\n  ·\n  \u003ca href=\"https://moov.io/blog/\"\u003eBlog\u003c/a\u003e\n  \u003cbr\u003e\n  \u003cbr\u003e\n\u003c/p\u003e\n\n[![GoDoc](https://godoc.org/github.com/moov-io/iso8583?status.svg)](https://godoc.org/github.com/moov-io/iso8583)\n[![Build Status](https://github.com/moov-io/iso8583/workflows/Go/badge.svg)](https://github.com/moov-io/iso8583/actions)\n[![Coverage Status](https://codecov.io/gh/moov-io/iso8583/branch/master/graph/badge.svg)](https://codecov.io/gh/moov-io/iso8583)\n[![Go Report Card](https://goreportcard.com/badge/github.com/moov-io/iso8583)](https://goreportcard.com/report/github.com/moov-io/iso8583)\n[![Repo Size](https://img.shields.io/github/languages/code-size/moov-io/iso8583?label=project%20size)](https://github.com/moov-io/iso8583)\n[![Apache 2 License](https://img.shields.io/badge/license-Apache2-blue.svg)](https://raw.githubusercontent.com/moov-io/iso8583/master/LICENSE)\n[![Slack Channel](https://slack.moov.io/badge.svg?bg=e01563\u0026fgColor=fffff)](https://slack.moov.io/)\n[![GitHub Stars](https://img.shields.io/github/stars/moov-io/iso8583)](https://github.com/moov-io/iso8583)\n[![Twitter](https://img.shields.io/twitter/follow/moov?style=social)](https://twitter.com/moov?lang=en)\n\n# moov-io/iso8583\n\nMoov's mission is to give developers an easy way to create and integrate bank processing into their own software products. Our open source projects are each focused on solving a single responsibility in financial services and designed around performance, scalability, and ease of use.\n\nISO8583 implements an ISO 8583 message reader and writer in Go. ISO 8583 is an international standard for card-originated financial transaction messages that defines both message format and communication flow. It's used by major card networks around the globe including Visa, Mastercard, and Verve. The standard supports card purchases, withdrawals, deposits, refunds, reversals, balance inquiries, inter-account transfers, administrative messages, secure key exchanges, and more.\n\n## Table of contents\n\n- [Project status](#project-status)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Go version support policy](#go-version-support-policy)\n- [How to](#how-to)\n\t- [Defining Message Specifications](#defining-message-specifications)\n    - [Working with ISO 8583 Messages](#working-with-iso-8583-messages)\n    - [Setting Message Data](#setting-message-data)\n    - [Getting Message Data](#getting-message-data)\n\t- [Inspecting message fields](#inspecting-message-fields)\n\t- [JSON Encoding and Decoding](#json-encoding-and-decoding)\n- [ISO8583 CLI](#cli)\n- [Learn more](#learn-more)\n- [Getting help](#getting-help)\n- [Contributing](#contributing)\n- [Related projects](#related-projects)\n\n## Project status\n\nMoov ISO8583 is a Go package that's been **thoroughly tested and trusted in the real world**. The project has proven its reliability and robustness in real-world, high-stakes scenarios. Please let us know if you encounter any missing feature/bugs/unclear documentation by opening up [an issue](https://github.com/moov-io/iso8583/issues/new) or asking on our [#iso8583 Community Slack channel](https://moov-io.slack.com/archives/C014UT7C3ST).\n. Thanks!\n\n## Installation\n\n```\ngo get github.com/moov-io/iso8583\n```\n\n## Quick Start\n\nThe following example demonstrates how to:\n- Define message structure using Go types\n- Pack a message for transmission\n- Unpack and parse a received message\n\n```go\n// Define types for the message fields\ntype Authorization struct {\n\tMTI                  string               `iso8583:\"0\"`  // Message Type Indicator\n\tPrimaryAccountNumber string               `iso8583:\"2\"`  // PAN\n\tProcessingCode       string               `iso8583:\"3\"`  // Processing code\n\tAmount               int64                `iso8583:\"4\"`  // Transaction amount\n\tSTAN                 string               `iso8583:\"11\"` // System Trace Audit Number\n\tExpirationDate       string               `iso8583:\"14\"` // YYMM\n\tAcceptorInformation  *AcceptorInformation `iso8583:\"43\"` // Merchant details\n}\n\ntype AcceptorInformation struct {\n\tName    string `index:\"1\"`\n\tCity    string `index:\"2\"`\n\tCountry string `index:\"3\"`\n}\n\nfunc Example() {\n\t// Pack the message\n\tmsg := iso8583.NewMessage(examples.Spec)\n\n\tauthData := \u0026Authorization{\n\t\tMTI:                  \"0100\",\n\t\tPrimaryAccountNumber: \"4242424242424242\",\n\t\tProcessingCode:       \"000000\",\n\t\tAmount:               2599,\n\t\tExpirationDate:       \"2201\",\n\t\tAcceptorInformation: \u0026AcceptorInformation{\n\t\t\tName:    \"Merchant Name\",\n\t\t\tCity:    \"Denver\",\n\t\t\tCountry: \"US\",\n\t\t},\n\t}\n\n\t// Set the field values\n\terr := msg.Marshal(authData)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Pack the message\n\tpacked, err := msg.Pack()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// send packed message to the server\n\t// ...\n\n\t// Unpack the message\n\tmsg = iso8583.NewMessage(Spec)\n\terr = msg.Unpack(packed)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Get the field values\n\tauthData = \u0026Authorization{}\n\terr = msg.Unmarshal(authData)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Print the entire message\n\tiso8583.Describe(msg, os.Stdout)\n}\n```\n\n## Go version support policy\n\n### Always up-to-date, never left behind\n\nWhile we strive to embrace the latest language enhancements, we also appreciate the need for a certain degree of backward compatibility. We understand that not everyone can update to the latest version immediately. Our philosophy is to move forward and embrace the new, but without leaving anyone immediately behind.\n\n#### Which versions do we support now?\n\nAs of today, we are supporting the following versions as referenced in the [setup-go action step](https://github.com/actions/setup-go#using-stableoldstable-aliases):\n\n* `stable` (which points to the current Go version)\n* `oldstable` (which points to the previous Go version)\n\nThe [setup-go](https://github.com/actions/setup-go) action automatically manages versioning, allowing us to always stay aligned with the latest and preceding Go releases.\n\n#### What does this mean for you?\n\nWhenever a new version of Go is released, we will update our systems and ensure that our project remains fully compatible with it. At the same time, we will continue to support the previous version. However, once a new version is released, the 'previous previous' version will no longer be officially supported. \n\n#### Continuous integration\n\nTo ensure our promise of support for these versions, we've configured our GitHub CI actions to test our code with both the current and previous versions of Go. This means you can feel confident that the project will work as expected if you're using either of these versions.\n\n## How to\n\n### Defining Message Specifications\n\nMost ISO 8583 implementations use confidential specifications that vary between payment systems, so you'll likely need to create your own specification. We provide example specifications in [/specs](./specs) directory that you can use as a starting point.\n\n#### Core Concepts\n\nThe package maps ISO 8583 concepts to the following types:\n\n- **MessageSpec** - Defines the complete message format with fields\n- **field.Spec** - Defines field's structure and behavior\n- **field.Field** - Represents an ISO 8583 data element with its value storing and handling logic:\n  - `field.String` - For alphanumeric fields\n  - `field.Numeric` - For numeric fields\n  - `field.Binary` - For binary data fields \n  - `field.Composite` - For structured data like TLV/BER-TLV fields or fields with positional subfields\n\nEach field specification consists of these elements:\n\n| Element          | Notes                                                                                                                                                                                                                       | Example                    |\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|\n| `Length`         | Maximum length of field (bytes, characters or digits), for both fixed and variable lengths.                                                                                                                                 | `10`                       |\n| `Description`    | Describes what the data field holds.                                                                                                                                                                                        | `\"Primary Account Number\"` |\n| `Enc`            | Sets the encoding type (`ASCII`, `Binary`, `BCD`, `LBCD`, `EBCDIC`).                                                                                                                                                           | `encoding.ASCII`           |\n| `Pref`           | Sets the encoding (`ASCII`, `Binary`, `BCD`, `EBCDIC`) of the field length and its type as fixed or variable (`Fixed`, `L`, `LL`, `LLL`, `LLLL`). The number of 'L's corresponds to the number of digits in a variable length. | `prefix.ASCII.Fixed`       |\n| `Pad` (optional) | Sets padding direction and type.                                                                                                                                                                                            | `padding.Left('0')`        |\n\nNote: While some ISO 8583 specifications do not have field 0 and field 1, we use them for MTI and Bitmap as they are technically regular fields. We use `String` field for MTI and `Bitmap` field for the bitmap.\n\nFor more advanced examples including handling of BER-TLV data, positional subfields, and various encoding types, see:\n- [message_test.go](message_test.go) - Complex message specifications and field types\n- [field/composite_test.go](field/composite_test.go) - Working with composite fields and subfields\n\n### Working with ISO 8583 Messages\n\nThe package provides two key operations for working with ISO 8583 messages:\n\n#### Building Messages\n\nTo build a message:\n1. Set message data using Go structs or individual field operations\n2. Pack the message into bytes using `Pack()`\n3. Send the bytes over the network\n\n```\nSet Data → Pack → Network →\n```\n\n#### Processing Messages\n\nWhen receiving a message:\n1. Unpack the received bytes using `Unpack()`\n2. Get message data using Go structs or individual field operations\n3. Process the data in your application\n\n```\n→ Network → Unpack → Get Data\n```\n\n### Setting Message Data\n\nAfter defining your specification, you can set message data in two ways: working with individual fields or using Go structs. While individual field access is available, using structs provides a cleaner approach.\n\n#### Using Go Structs (Recommended)\n\nDefine a struct that maps your business data to ISO 8583 fields using native Go types and `iso8583` tags:\n\n```go\ntype Authorization struct {\n    MTI                  string    `iso8583:\"0\"`  // Message Type Indicator\n    PrimaryAccountNumber string    `iso8583:\"2\"`  // PAN\n    ProcessingCode       string    `iso8583:\"3\"`  // Processing code\n    Amount               int64     `iso8583:\"4\"`  // Transaction amount\n    STAN                 string    `iso8583:\"11\"` // System Trace Audit Number\n    LocalTime            string    `iso8583:\"12\"` // HHmmss\n    LocalDate            string    `iso8583:\"13\"` // MMDD\n    MerchantType         string    `iso8583:\"18\"` // Merchant category code\n    AcceptorInfo         *Acceptor `iso8583:\"43\"` // Merchant details\n}\n\ntype Acceptor struct {\n    Name    string `index:\"1\"`\n    City    string `index:\"2\"`\n    Country string `index:\"3\"`\n}\n```\n\nThen create and populate your message:\n\n```go\n// Create new message\nmsg := iso8583.NewMessage(Spec)\n\n// Prepare transaction data\nauth := \u0026Authorization{\n    MTI:                  \"0100\",\n    PrimaryAccountNumber: \"4242424242424242\",\n    ProcessingCode:       \"000000\",\n    Amount:               9999,\n    STAN:                 \"000123\",\n    LocalTime:            \"152059\",\n    LocalDate:            \"0205\",\n    MerchantType:         \"5411\",\n    AcceptorInfo: \u0026Acceptor{\n        Name:    \"ACME Store\",\n        City:    \"New York\",\n        Country: \"US\",\n    },\n}\n\n// Marshal data into message\nerr := msg.Marshal(auth)\nif err != nil {\n    panic(err)\n}\n\n// Pack for transmission\ndata, err := msg.Pack()\nif err != nil {\n    panic(err)\n}\n// data is ready to be sent\n```\n\nIf you want empty values to be included in the message, you can use the `keepzero` option in the `iso8583` field tag:\n\n```go\ntype Authorization struct {\n    // ...\n    AdditionalData       string    `iso8583:\"48,keepzero\"` // Additional data\n}\n```\n\nFor such fields, the field bit will be set in the bitmap, but the value will be empty. You should set padding for such fields to ensure the field length is correct.\n\n#### Working with Individual Fields\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to show individual field operations\u003c/summary\u003e\n\nFor simple operations, you can set fields directly:\n\n```go\nmsg := iso8583.NewMessage(spec)\n\n// Set MTI\nmsg.MTI(\"0100\")\n\n// Set field values as strings\nerr := msg.Field(2, \"4242424242424242\")\nerr = msg.Field(3, \"000000\")\nerr = msg.Field(4, \"9999\")\n\n// For binary fields\nerr = msg.BinaryField(52, []byte{0x1A, 0x2B, 0x3C, 0x4D})\n\n// Pack for transmission\ndata, err := msg.Pack()\n```\n\nNote: Individual field operations are limited to string or []byte values. The underlying field handles type conversion.\n\u003c/details\u003e\n\n#### Legacy: Using Field Types\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to show legacy field type usage\u003c/summary\u003e\n\nIn previous versions, it was common to use package-specific field types. While still supported, we recommend using native Go types instead:\n\n```go\ntype Authorization struct {\n    MTI         *field.String `index:\"0\"`\n    PAN         *field.String `index:\"2\"`\n    Amount      *field.Numeric `index:\"4\"`\n    LocalTime   *field.String `index:\"12\"`\n}\n\nauth := \u0026Authorization{\n    MTI:       field.NewStringValue(\"0100\"),\n    PAN:       field.NewStringValue(\"4242424242424242\"),\n    Amount:    field.NewNumericValue(9999),\n    LocalTime: field.NewStringValue(\"152059\"),\n}\n\nmsg.Marshal(auth)\n```\n\u003c/details\u003e\n\n### Getting Message Data\n\nWhen you receive a packed ISO 8583 message, you can unpack and access its data in two ways: using Go structs or accessing individual fields. Using structs provides a cleaner approach to working with message data.\n\n#### Using Go Structs (Recommended)\n\nDefine a struct matching your expected message format using native Go types:\n\n```go\ntype Authorization struct {\n    MTI                  string    `iso8583:\"0\"`  // Message Type Indicator\n    PrimaryAccountNumber string    `iso8583:\"2\"`  // PAN\n    ProcessingCode       string    `iso8583:\"3\"`  // Processing code\n    Amount              int64     `iso8583:\"4\"`  // Transaction amount\n    STAN                string    `iso8583:\"11\"` // System Trace Audit Number\n    LocalTime           string    `iso8583:\"12\"` // HHmmss\n    LocalDate           string    `iso8583:\"13\"` // MMDD\n    MerchantType        string    `iso8583:\"18\"` // Merchant category code\n    AcceptorInfo        *Acceptor `iso8583:\"43\"` // Merchant details\n}\n\ntype Acceptor struct {\n    Name    string `index:\"1\"`\n    City    string `index:\"2\"`\n    Country string `index:\"3\"`\n}\n```\n\nThen unpack and parse your message:\n\n```go\n// Create message with appropriate spec\nmsg := iso8583.NewMessage(specs.Spec87ASCII)\n\n// Unpack received bytes\nerr := msg.Unpack(receivedData)\nif err != nil {\n    panic(err)\n}\n\n// Parse into struct\nvar auth Authorization\nerr = msg.Unmarshal(\u0026auth)\nif err != nil {\n    panic(err)\n}\n\n// Work with parsed data\nfmt.Printf(\"Transaction amount: %d\\n\", auth.Amount)\nfmt.Printf(\"Merchant: %s, %s\\n\", auth.AcceptorInfo.Name, auth.AcceptorInfo.City)\n\n// Print full message contents (with sensitive data masked)\niso8583.Describe(msg, os.Stdout)\n```\n\n#### Working with Individual Fields\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to show individual field operations\u003c/summary\u003e\n\nFor quick access to specific fields:\n\n```go\nmsg := iso8583.NewMessage(spec)\nerr := msg.Unpack(receivedData)\n\n// Get MTI\nmti, err := msg.GetMTI()\n\n// Get field values as strings\npan, err := msg.GetString(2)\nproc, err := msg.GetString(3)\namount, err := msg.GetString(4)\n\n// Get binary field values\npinData, err := msg.GetBytes(52)\n```\n\nNote: Individual field access is limited to string or []byte values.\n\u003c/details\u003e\n\n#### Legacy: Using Field Types\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to show legacy field type usage\u003c/summary\u003e\n\nPreviously, it was common to use package-specific field types. While still supported, we recommend using native Go types instead:\n\n```go\ntype LegacyAuthorization struct {\n    MTI         *field.String  `index:\"0\"`\n    PAN         *field.String  `index:\"2\"`\n    Amount      *field.Numeric `index:\"4\"`\n    LocalTime   *field.String  `index:\"12\"`\n}\n\nvar auth LegacyAuthorization\nmsg.Unmarshal(\u0026auth)\n\nfmt.Println(auth.MTI.Value())\nfmt.Println(auth.Amount.Value())\n```\n\u003c/details\u003e\n\n### Inspecting Message Fields\n\nThere is a `Describe` function in the package that displays all message fields\nin a human-readable way. Here is an example of how you can print message fields\nwith their values to STDOUT:\n\n```go\n// print message to os.Stdout\niso8583.Describe(message, os.Stdout)\n```\n\nand it will produce the following output:\n\n```\nMTI........................................: 0100\nBitmap.....................................: 000000000000000000000000000000000000000000000000\nBitmap bits................................: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000\nF000 Message Type Indicator................: 0100\nF002 Primary Account Number................: 4242****4242\nF003 Processing Code.......................: 123456\nF004 Transaction Amount....................: 100\nF020 PAN Extended Country Code.............: 4242****4242\nF035 Track 2 Data..........................: 4000****0506=2512111123400001230\nF036 Track 3 Data..........................: 011234****3445=724724000000000****00300XXXX020200099010=********************==1=100000000000000000**\nF045 Track 1 Data..........................: B4815****1896^YATES/EUGENE L^^^356858      00998000000\nF052 PIN Data..............................: 12****78\nF055 ICC Data – EMV Having Multiple Tags...: ICC  ... Tags\n```\n\nby default, we apply `iso8583.DefaultFilters` to mask the values of the fields\nwith sensitive data. You can define your filter functions and redact specific\nfields like this:\n\n```go\nfilterAll = func(in string, data field.Field) string {\n\trunesInString := utf8.RuneCountInString(in)\n\n\treturn strings.Repeat(\"*\", runesInString)\n}\n\n// filter only value of the field 2\niso8583.Describe(message, os.Stdout, filterAll(2, filterAll))\n\n// outputs:\n// F002 Primary Account Number................: ************\n```\n\nIf you want to view unfiltered values, you can use no-op filters `iso8583.DoNotFilterFields` that we defined:\n\n```go\n// display unfiltered field values\niso8583.Describe(message, os.Stdout, DoNotFilterFields()...)\n```\n\n### JSON Encoding and Decoding\n\nYou can serialize message into JSON format:\n\n```go\njsonMessage, err := json.Marshal(message)\n```\n\nit will produce the following JSON (bitmap is not included, as it's only used to unpack message from the binary representation):\n\n```json\n{\n   \"0\":\"0100\",\n   \"2\":\"4242424242424242\",\n   \"3\":123456,\n   \"4\":\"100\"\n}\n```\n\nAlso, you can unmarshal JSON into `iso8583.Message`:\n\n```go\ninput := `{\"0\":\"0100\",\"2\":\"4242424242424242\",\"4\":\"100\"}`\n\nmessage := NewMessage(spec)\nif err := json.Unmarshal([]byte(input), message); err != nil {\n    // handle err\n}\n\n// access indidual fields or using struct\n```\n\n### Sending and Receiving Messages\n\nWhile this package handles message formatting and parsing, for network operations we recommend using our companion package [moov-io/iso8583-connection](https://github.com/moov-io/iso8583-connection). It provides robust client/server communication with features like:\n\n- Message sending and receiving\n- Request/response matching\n- Connection management\n- Support for both acquiring and issuing services\n- Testing utilities\n\n#### Network Headers\n\nAll messages between the client/server (ISO host and endpoint) have a message length header. It can be a 4 bytes ASCII or 2 bytes BCD encoded length or any other custom header format. We provide a `network.Header` interface to simplify the reading and writing of the network header.\n\nFollowing network headers implementations are available in [network](./network) package:\n\n* Binary2Bytes - message length encoded in 2 bytes, e.g, {0x00 0x73} for 115\n  bytes of the message\n* ASCII4Bytes - message length encoded in 4 bytes ASCII, e.g., 0115 for 115\n  bytes of the message\n* BCD2Bytes - message length encoded in 2 bytes BCD, e.g, {0x01, 0x15} for 115\n  bytes of the message\n* VMLH (Visa Message Length Header) - message length encoded in 2 bytes + 2 reserved bytes\n\nYou can read network header from the network connection like this:\n\n```go\nheader := network.NewBCD2BytesHeader()\n_, err := header.ReadFrom(conn)\nif err != nil {\n\t// handle error\n}\n\n// Make a buffer to hold message\nbuf := make([]byte, header.Length())\n// Read the incoming message into the buffer.\nread, err := io.ReadFull(conn, buf)\nif err != nil {\n\t// handle error\n}\nif reqLen != header.Length() {\n\t// handle error\n}\n\nmessage := iso8583.NewMessage(specs.Spec87ASCII)\nmessage.Unpack(buf)\n```\n\nHere is an example of how to write network header into network connection:\n\n```go\nheader := network.NewBCD2BytesHeader()\npacked, err := message.Pack()\nif err != nil {\n\t// handle error\n}\nheader.SetLength(len(packed))\n_, err = header.WriteTo(conn)\nif err != nil {\n\t// handle error\n}\nn, err := conn.Write(packed)\nif err != nil {\n\t// handle error\n}\n```\n\n## CLI\n\nCLI suports following command:\n\n* `display` to display ISO8583 message in a human-readable format\n\n### Installation\n\n`iso8583` CLI is available as downloadable binaries from the [releases page](https://github.com/moov-io/iso8583/releases/latest) for MacOS, Windows and Linux.\n\nHere is an example how to install MacOS version:\n\n```\nwget -O ./iso8583 https://github.com/moov-io/iso8583/releases/download/v0.4.6/iso8583_0.4.6_darwin_amd64 \u0026\u0026 chmod +x ./iso8583\n```\n\nNow you can run CLI:\n\n```\n➜ ./iso8583\nWork seamlessly with ISO 8583 from the command line.\n\nUsage:\n  iso8583 \u003ccommand\u003e [flags]\n\nAvailable commands:\n  describe: display ISO 8583 file in a human-readable format\n```\n\n\n### Display\n\nTo display ISO8583 message in a human-readable format\n\nExample:\n\n```\n➜ ./bin/iso8583 describe msg.bin\nMTI........................................: 0100\nBitmap.....................................: 000000000000000000000000000000000000000000000000\nBitmap bits................................: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000\nF000 Message Type Indicator................: 0100\nF002 Primary Account Number................: 4242****4242\nF003 Processing Code.......................: 123456\nF004 Transaction Amount....................: 100\nF020 PAN Extended Country Code.............: 4242****4242\nF035 Track 2 Data..........................: 4000****0506=2512111123400001230\nF036 Track 3 Data..........................: 011234****3445=724724000000000****00300XXXX020200099010=********************==1=100000000000000000**\nF045 Track 1 Data..........................: B4815****1896^YATES/EUGENE L^^^356858      00998000000\nF052 PIN Data..............................: 12****78\nF055 ICC Data – EMV Having Multiple Tags...: ICC  ... Tags\n```\n\nYou can specify which of the built-in specs to use to the describe message via\nthe `spec` flag:\n\n```\n➜ ./bin/iso8583 describe -spec spec87ascii msg.bin\n```\n\nYou can also define your spec in JSON format and describe message using the spec file with `spec-file` flag:\n\n```\n➜ ./bin/iso8583 describe -spec-file ./examples/specs/spec87ascii.json msg.bin\n```\n\nPlease, check the example of the JSON spec file [spec87ascii.json](./examples/specs/spec87ascii.json).\n\n\n## Learn more\n\n- [How to Define Composite Fields](./docs/composite-fields.md)\n- [Intro to ISO 8583](./docs/intro.md)\n- [Message Type Indicator](./docs/mti.md)\n- [Bitmaps](./docs/bitmap.md)\n- [How Tos](./docs/howtos.md)\n- [Data Fields](./docs/data-elements.md)\n- [Mastering ISO 8583 messages with Golang](https://alovak.com/2024/08/15/mastering-iso-8583-messages-with-golang/)\n- [Mastering ISO 8583 Message Networking with Golang](https://alovak.com/2024/08/27/mastering-iso-8583-message-networking-with-golang/)\n- [ISO 8583 Terms and Definitions](https://www.iso.org/obp/ui/#iso:std:iso:8583:-1:ed-1:v1:en)\n\n## Getting help\n\n channel | info\n ------- | -------\n[Project Documentation](https://github.com/moov-io/iso8583/tree/master/docs) | Our project documentation available online.\nTwitter [@moov](https://twitter.com/moov)\t| You can follow Moov.io's Twitter feed to get updates on our project(s). You can also tweet us questions or just share blogs or stories.\n[GitHub Issue](https://github.com/moov-io/iso8583/issues/new) | If you are able to reproduce a problem please open a GitHub Issue under the specific project that caused the error.\n[moov-io slack](https://slack.moov.io/) | Join our slack channel (`#iso8583`) to have an interactive discussion about the development of the project.\n\n## Contributing\n\n**While [Spec87ASCII](./specs/spec87ascii.go) is appropriate for most users, we hope to see improvements and variations of this specification for different systems by the community. Please do not hesitate to contribute issues, questions, or PRs to cover new use cases. Tests are also appreciated if possible!**\n\nPlease review our [Contributing guide](CONTRIBUTING.md) and [Code of Conduct](CODE_OF_CONDUCT.md) to get started! Check out our [issues for first time contributors](https://github.com/moov-io/iso8583/contribute) for something to help out with.\n\nThis project uses [Go Modules](https://go.dev/blog/using-go-modules) and Go v1.18 or newer. See [Golang's install instructions](https://golang.org/doc/install) for help setting up Go. You can download the source code and we offer [tagged and released versions](https://github.com/moov-io/iso8583/releases/latest) as well. We highly recommend you use a tagged release for production.\n\n## Related projects\nAs part of Moov's initiative to offer open source fintech infrastructure, we have a large collection of active projects you may find useful:\n\n- [Moov ACH](https://github.com/moov-io/ach) provides ACH file generation and parsing, supporting all Standard Entry Codes for the primary method of money movement throughout the United States.\n\n- [Moov Watchman](https://github.com/moov-io/watchman) offers search functions over numerous trade sanction lists from the United States and European Union.\n\n- [Moov Fed](https://github.com/moov-io/fed) implements utility services for searching the United States Federal Reserve System such as ABA routing numbers, financial institution name lookup, and FedACH and Fedwire routing information.\n\n- [Moov Wire](https://github.com/moov-io/wire) implements an interface to write files for the Fedwire Funds Service, a real-time gross settlement funds transfer system operated by the United States Federal Reserve Banks.\n\n- [Moov ImageCashLetter](https://github.com/moov-io/imagecashletter) implements Image Cash Letter (ICL) files used for Check21, X.9 or check truncation files for exchange and remote deposit in the U.S.\n\n- [Moov Metro2](https://github.com/moov-io/metro2) provides a way to easily read, create, and validate Metro 2 format, which is used for consumer credit history reporting by the United States credit bureaus.\n\n\n## License\n\nApache License 2.0 - See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoov-io%2Fiso8583","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoov-io%2Fiso8583","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoov-io%2Fiso8583/lists"}