The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Fix::Checksum::XS - Fast FIX Checksum calculations from Perl

SYNOPSIS

  use Net::Fix::Checksum::XS qw(generate_checksum replace_checksum validate_checksum);

  # Generate a checksum and return it as a 0-padded string. Any existing
  # checksum field is ignored.
  my $checksum = generate_checksum($fixmsg);

  # Append/replace a checksum to a fix message. Any existing checksum field is
  # ignored and replaced.
  my $newmsg = replace_checksum($fixmsg);

  # Validate checksum of given message. Return true (1) if checksum is present
  # and valid.
  validate_checksum($fixmsg) or die "Invalid checksum";

All functions return undef if passed a string that doe not end with a SOH. See "FUNCTIONS" for other possible return values.

DESCRIPTION

This module calculates, validates and replace checksum on FIX messages. It comes with a simple interface written in C for speed.

EXPORT

None by default. All three methods can be exported.

FUNCTIONS

generate_checksum

  my $checksum = generate_checksum($fixmsg);

Generate a checksum and return it as a 0-padded string. Any existing checksum field is ignored.

Returns undef if the message does not end with a SOH. No other validity checks are performed.

replace_checksum

  my $newmsg = replace_checksum($fixmsg);

Append/replace a checksum to a SOH-delimited fix message. Any existing checksum field is ignored and replaced.

Returns undef if the message does not end with a SOH or if the message exceeds the maximum allowed length (see "BUGS" for more info).

validate_checksum

  my $result = validate_checksum($fixmsg);

Validate checksum of given message. Return 1 if checksum is present and valid, and 0 if the checksum is invalid.

Returns undef if the message does not end with a SOH or if the checksum field is malformed or invalid.

BUGS

For speed and simplicity, replace_checksum() is limited to 4095 characters messages by default (including all fields, checksum and trailing separator). This can be changed at compile time; see Makefile.PL.

Functions should take a delimiter optional argument. It should be very easy to implement once we get past XS glue; I just never looked into it.

SEE ALSO

The code repository is mirrored on https://github.com/dermoth/Net-Fix-Checksum-XS

AUTHOR

Thomas Guyot-Sionnest <tguyot@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2015 by Thomas Guyot-Sionnest <tguyot@gmail.com>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.20.2 or, at your option, any later version of Perl 5 you may have available.