mciutil package

Submodules

mciutil.mciutil module

mciutil function library

Contains functions to work with MasterCard formatted files

mciutil.mciutil.b(string)[source]

Create a byte string field - Python 2.x

Parameters:string – input string
Returns:a byte array containing the string
mciutil.mciutil.block(unblocked_data)[source]

Blocks a list of records to 1014 byte blocked VBS records

Parameters:unblocked_data – list containing records
Returns:string containing repeating binary length(4) + data records in a single string including 1014 block markers
mciutil.mciutil.flip_message_encoding(message, bit_config, source_format)[source]

Flip the encoding of an ISO8583 style file between ASCII and EBCDIC

Parameters:
  • message – The data to be flipped
  • bit_config – dictionary of bit mapping configuration
  • source_format – The encoding of the source {ebcdic, ascii}
Returns:

message encoded

mciutil.mciutil.get_message_elements(message, bit_config, source_format)[source]

Convert ISO8583 style message to dictionary

Parameters:message – The message in ISO8583 based format
  • Message Type indicator - 4 bytes
  • Binary bitmap - 16 bytes (Reads DE1 and DE2)
  • Message data - Remainder of record
Parameters:
  • bit_config – dictionary of bit mapping configuration
  • source_format – string indicating encoding of data (ascii|ebcdic)
Returns:

dictionary of message elements

  • key = ‘MTI’ message type indicator
  • key = ‘DEx’ data elements
  • key = ‘PDSxxxx’ private data fields
  • key = ‘TAGxxxx’ icc fields
mciutil.mciutil.unblock(blocked_data)[source]

Unblocks a 1014 byte blocked string

Parameters:blocked_data – String containing 1014 blocked data or file
Returns:list of records in file
mciutil.mciutil.vbs_pack(records)[source]

Packs a list of records into a variable blocked string

Parameters:records – list containing records to be packed
Returns:string containing repeating binary length(4) + data records in a single string
mciutil.mciutil.vbs_unpack(vbs_data)[source]

Unpacks a variable blocked string into a list of records

Parameters:vbs_data – string containing repeating binary length(4) + data records in a single string.
Returns:list of unpacked records

Module contents

mciutil

Shared functions for working with MasterCard files