codec8583

package
v0.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2021 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Tag8583 = "iso8583"

Variables

View Source
var (
	// ASCII encodes/decodes ASCII charset of the ISO 8583 MTI/bitmaps/fields.
	ASCII = NOPCharset
	// EBCDIC encodes/decodes EBCDIC charset of the ISO 8583 MTI/bitmaps/fields.
	EBCDIC = Charset{EncodeEbcdic, DecodeEbcdic}
	// NOPCharset is a "no operation" charset encoder/decoder.
	NOPCharset = Charset{}
)
View Source
var (
	// MTIAsciiCodec encodes/decodes ISO 8583 MTI (Message Type Indicator)
	// the size of which is 4 bytes in ASCII character encoding.
	MTIAsciiCodec = FIX{4, ASCII, EncodeMTI, DecodeMTI}
	// MTIEbcdicCodec encodes/decodes ISO 8583 MTI (Message Type Indicator)
	// the size of which is 4 bytes in EBCDIC character encoding.
	MTIEbcdicCodec = FIX{4, EBCDIC, EncodeMTI, DecodeMTI}
	// BitmapCodec encodes/decodes ISO 8583 bitmap the size of which is 8 bytes (64 bit).
	BitmapCodec = FIX{8, NOPCharset, EncBitmap, DecBitmap}
)
View Source
var (
	MastercardMarshaler   = NewMarshaler(Mastercard)
	MastercardUnmarshaler = NewUnmarshaler(Mastercard)

	// MastercardTruncate decoder and truncator (masker) of the decoded ISO 8583 message.
	MastercardTruncate             = make(Format)
	MastercardUnmarshalerTruncator Unmarshaler

	// MastercardHash256 decoder and hasher (obfuscatator) of the ISO 8583 message.
	MastercardHash256              = make(Format)
	MastercardUnmarshalerHasher256 Unmarshaler

	// MastercardHashed256 coder/decoder of the ISO 8583 obfuscatated message.
	MastercardHashed256            = make(Format)
	MastercardHashed256Marshaler   Marshaler
	MastercardHashed256Unmarshaler Unmarshaler
)
View Source
var (
	TSYSMarshaler   = NewMarshaler(TSYS)
	TSYSUnmarshaler = NewUnmarshaler(TSYS)
)
View Source
var Mastercard = Format{}/* 130 elements not displayed */

Mastercard is a format of the ISO 8583 message which maps the codecs to MIT/bitmaps/each individual field.

View Source
var TSYS = Format{}/* 130 elements not displayed */

TSYS is a format of the ISO 8583 message which maps the codecs to MIT/bitmaps/each individual field.

Functions

func DecA

func DecA(_ Hasher, codec Codec, enc []byte) ([]byte, error)

DecA intends to decode Alpha, including blanks <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func DecAN

func DecAN(_ Hasher, codec Codec, enc []byte) ([]byte, error)

DecAN intends to decode alphanumeric <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func DecANS

func DecANS(_ Hasher, codec Codec, enc []byte) ([]byte, error)

DecANS intends to decode alphabetic, numeric and special characters <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func DecB

func DecB(_ Hasher, _ Codec, enc []byte) ([]byte, error)

DecB intends to decode binary data <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func DecBitmap

func DecBitmap(_ Hasher, _ Codec, enc []byte) ([]byte, error)

DecBitmap intends to decode the ISO 8583 bitmap.

func DecFirstPANTruncate

func DecFirstPANTruncate(_ Hasher, codec Codec, enc []byte) ([]byte, error)

DecFirstPANTruncate intends to decode and truncate (mask) PAN located at the beginning of the byte slice, 1234567890123456D99122011969100000377 -> 1234XXXXXXXX3456D99122011969100000377

func DecHash256

func DecHash256(h Hasher, codec Codec, enc []byte) ([]byte, error)

DecHash256 intends to decode and hash (obfuscate) like Central Bank of the Russian Federation obfuscates PAN, using the SHA 256 sum function.

func DecN

func DecN(_ Hasher, codec Codec, enc []byte) ([]byte, error)

DecN intends to decode numeric values only <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func DecNS

func DecNS(_ Hasher, codec Codec, enc []byte) ([]byte, error)

DecNS intends to decode numeric and special characters only <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func DecNullify

func DecNullify(_ Hasher, _ Codec, _ []byte) ([]byte, error)

DecNullify just skips the field.

func DecPANTruncate

func DecPANTruncate(_ Hasher, codec Codec, enc []byte) ([]byte, error)

DecPANTruncate intends to decode and truncate (mask) PAN, 1234567890123456 -> 1234XXXXXXXX3456.

func DecTSYSBitmap64R

func DecTSYSBitmap64R(_ Hasher, _ Codec, data []byte) ([]byte, error)

DecTSYSBitmap64R intends to decode TSYS specific bitmap the size of which is 8 bytes (64 bit) plus one additional optional byte for the "R" flag.

func DecXN

func DecXN(_ Hasher, codec Codec, enc []byte) ([]byte, error)

DecXN intends to decode numeric (amount) values, where the first byte is either 'C' to indicate a positive or Credit value, or 'D' to indicate a negative or Debit value, followed by the numeric value (using n digits) <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func DecZ

func DecZ(_ Hasher, codec Codec, enc []byte) ([]byte, error)

DecZ intends to decode tracks 2 and 3 code set as defined in ISO/IEC 7813 and ISO/IEC 4909 respectively <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>, <https://en.wikipedia.org/wiki/ISO/IEC_7813>.

func DecodeEbcdic

func DecodeEbcdic(src []byte) ([]byte, error)

DecodeEbcdic intends to decode all bytes in EBCDIC character encoding except the null character.

func DecodeMTI

func DecodeMTI(_ Hasher, codec Codec, enc []byte) ([]byte, error)

DecodeMTI intends to decode the ISO 8583 MTI (Message Type Indicator).

func EncA

func EncA(_ Hasher, codec Codec, dec []byte) ([]byte, error)

EncA intends to encode Alpha, including blanks <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func EncAN

func EncAN(_ Hasher, codec Codec, dec []byte) ([]byte, error)

EncAN intends to encode alphanumeric <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func EncANS

func EncANS(_ Hasher, codec Codec, dec []byte) ([]byte, error)

EncANS intends to encode alphabetic, numeric and special characters <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func EncB

func EncB(_ Hasher, _ Codec, dec []byte) ([]byte, error)

EncB intends to encode binary data <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func EncBitmap

func EncBitmap(_ Hasher, _ Codec, dec []byte) ([]byte, error)

EncBitmap intends to encode the ISO 8583 bitmap.

func EncN

func EncN(_ Hasher, codec Codec, dec []byte) ([]byte, error)

EncN intends to encode numeric values only <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func EncNS

func EncNS(_ Hasher, codec Codec, dec []byte) ([]byte, error)

EncNS intends to encode numeric and special characters only <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func EncTSYSBitmap64R

func EncTSYSBitmap64R(_ Hasher, _ Codec, data []byte) ([]byte, error)

EncTSYSBitmap64R intends to encode TSYS specific bitmap the size of which is 8 bytes (64 bit) plus one additional optional byte for the "R" flag.

func EncXN

func EncXN(_ Hasher, codec Codec, dec []byte) ([]byte, error)

EncXN intends to encode numeric (amount) values, where the first byte is either 'C' to indicate a positive or Credit value, or 'D' to indicate a negative or Debit value, followed by the numeric value (using n digits) <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>.

func EncZ

func EncZ(_ Hasher, codec Codec, dec []byte) ([]byte, error)

EncZ intends to encode tracks 2 and 3 code set as defined in ISO/IEC 7813 and ISO/IEC 4909 respectively <https://en.wikipedia.org/wiki/ISO_8583#Data_elements>, <https://en.wikipedia.org/wiki/ISO/IEC_7813>.

func EncodeEbcdic

func EncodeEbcdic(src []byte) ([]byte, error)

EncodeEbcdic intends to encode all bytes in EBCDIC character encoding except the null character.

func EncodeMTI

func EncodeMTI(_ Hasher, codec Codec, dec []byte) ([]byte, error)

EncodeMTI intends to encode the ISO 8583 MTI (Message Type Indicator).

func NewHashify

func NewHashify() hashify

func NewMarshaler

func NewMarshaler(f Format) marshal

func NewUnmarshaler

func NewUnmarshaler(f Format) unmarshal

Types

type Charset

type Charset struct {
	Enc EncodeCharsetFunc
	Dec DecodeCharsetFunc
}

Charset encodes/decodes charset of the ISO 8583 MTI/bitmaps/fields.

func (Charset) Decode

func (c Charset) Decode(data []byte) ([]byte, error)

func (Charset) Encode

func (c Charset) Encode(data []byte) ([]byte, error)

type Codec

type Codec interface {
	Encode(Hasher, []byte) ([]byte, error)
	Decode(Hasher, []byte) ([]byte, error)
	Read(io.Reader) ([]byte, error)
	Write(io.Writer, []byte) error
	Len() int
	Charset() Charset
}

Codec encodes/decodes a MTI/bitmaps/fields of the ISO 8583 message.

type DecodeCharsetFunc

type DecodeCharsetFunc func([]byte) ([]byte, error)

DecodeCharsetFunc decodes charset of the ISO 8583 MTI/bitmaps/fields.

type DecodeFunc

type DecodeFunc func(Hasher, Codec, []byte) ([]byte, error)

DecodeFunc decodes ISO 8583 MTI/bitmaps/fields.

type EncodeCharsetFunc

type EncodeCharsetFunc func([]byte) ([]byte, error)

EncodeCharsetFunc encodes charset of the ISO 8583 MTI/bitmaps/fields.

type EncodeFunc

type EncodeFunc func(Hasher, Codec, []byte) ([]byte, error)

EncodeFunc encodes ISO 8583 MTI/bitmaps/fields.

type FIX

type FIX struct {
	Length int
	ChrSet Charset
	Enc    EncodeFunc
	Dec    DecodeFunc
}

FIX is an codec for a fixed length fields/MTI/bitmaps of the ISO 8583.

func (FIX) Charset

func (c FIX) Charset() Charset

func (FIX) Decode

func (c FIX) Decode(h Hasher, enc []byte) ([]byte, error)

func (FIX) Encode

func (c FIX) Encode(h Hasher, dec []byte) ([]byte, error)

func (FIX) Len

func (c FIX) Len() int

func (FIX) Read

func (c FIX) Read(r io.Reader) ([]byte, error)

Read reads a field with fixed length.

func (FIX) Write

func (c FIX) Write(w io.Writer, data []byte) error

Write writes a field with fixed length.

type Format

type Format map[int]Codec

Format maps a codes to a MIT/bitmaps/each individual field of the ISO 8583 message.

type Hasher

type Hasher interface {
	Sum256(data []byte) ([]byte, error)
}

type LLLVAR

type LLLVAR struct {
	MaxLen int
	ChrSet Charset
	Enc    EncodeFunc
	Dec    DecodeFunc
}

LLLVAR is an codec for the variable length fields of the ISO 8583, the length coded in 3 bytes.

func (LLLVAR) Charset

func (c LLLVAR) Charset() Charset

func (LLLVAR) Decode

func (c LLLVAR) Decode(h Hasher, enc []byte) ([]byte, error)

func (LLLVAR) Encode

func (c LLLVAR) Encode(h Hasher, dec []byte) ([]byte, error)

func (LLLVAR) Len

func (c LLLVAR) Len() int

func (LLLVAR) Read

func (c LLLVAR) Read(r io.Reader) ([]byte, error)

Read reads a field with variable length (VAR).

func (LLLVAR) Write

func (c LLLVAR) Write(w io.Writer, data []byte) error

Write writes a field with variable length (VAR).

type LLVAR

type LLVAR struct {
	MaxLen int
	ChrSet Charset
	Enc    EncodeFunc
	Dec    DecodeFunc
}

LLVAR is an codec for the variable length fields of the ISO 8583, the length coded in 2 bytes.

func (LLVAR) Charset

func (c LLVAR) Charset() Charset

func (LLVAR) Decode

func (c LLVAR) Decode(h Hasher, enc []byte) ([]byte, error)

func (LLVAR) Encode

func (c LLVAR) Encode(h Hasher, dec []byte) ([]byte, error)

func (LLVAR) Len

func (c LLVAR) Len() int

func (LLVAR) Read

func (c LLVAR) Read(r io.Reader) ([]byte, error)

Read reads a field with variable length (VAR).

func (LLVAR) Write

func (c LLVAR) Write(w io.Writer, data []byte) error

Write writes a field with variable length (VAR).

type LVAR

type LVAR struct {
	MaxLen int
	ChrSet Charset
	Enc    EncodeFunc
	Dec    DecodeFunc
}

LVAR is an codec for the variable length fields of the ISO 8583, the length coded in 1 byte.

func (LVAR) Charset

func (c LVAR) Charset() Charset

func (LVAR) Decode

func (c LVAR) Decode(h Hasher, enc []byte) ([]byte, error)

func (LVAR) Encode

func (c LVAR) Encode(h Hasher, dec []byte) ([]byte, error)

func (LVAR) Len

func (c LVAR) Len() int

func (LVAR) Read

func (c LVAR) Read(r io.Reader) ([]byte, error)

Read reads a field with variable length (VAR).

func (LVAR) Write

func (c LVAR) Write(w io.Writer, data []byte) error

Write writes a field with variable length (VAR).

type Marshaler

type Marshaler interface {
	Marshal(interface{}) ([]byte, error)
}

type Unmarshaler

type Unmarshaler interface {
	Unmarshal(raw []byte, v interface{}) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL