The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Crypt::AoN::Util - Perl extension for Utility functions for Crypt::AoN

SYNOPSIS

  use Crypt::AoN::Util qw/:all/;

  $key = newKey(size=>128, return=>'ascii');
  @brokenString = breakString(string=>$string, size=>$size);
  addLength_andPad(array=>\@array, size=>$packetSize);
  remLength_andPad(array=>\@array);
  $charString = largeNumToChar(size=>$size, number=>$number);

DESCRIPTION

This provides utility functions needed in Crypt::AoN that could not be found elsewhere. If there are equivelant functions in some other more general module, please let me know.

$key = newKey(size=>$size,return=>$type) 'size' is the number of bits to be in the created key. it can be any value greater than 0, 128 is the default if nothing is passed 'return' can currently be 'ascii', 'hex', 'base64', or 'int'. If ascii, the size of the returned value will be exactly that passed, if hex, it will be twice that passed, if base64, 4/3 that passed, if int, the bitsize will be that passed, or possibly a few bits smaller.

@brokenString = breakString(string=>$string, size=>$size) This function breaks up a string into an array with each item in the array of length given. This does no padding, so the last item in the array may be shorter. Please see addLength_andPad. 'size' is the number of bytes, or characters each segment should be 'string' is the string to be broken

addLength_andPad(array=>\@array, size=>$packetSize) This function takes an array of strings and appends the total length of all the items in the array to the end of the array, padding with specified characters to make the last item in teh array the same length as the rest of the items. 'array' is a reference to the array to be processed. This is processed inline, the array you pass will be changed when the function returns. The array must conform to a few guidelines to work with this function. All elements other than the last must be the same length. The last element must be less than or equal to the size of the rest. The elements must be at least 4 bytes large. 'size' is the packet size in bytes(ie:characters). this must be greater than 4 'padding' is a string containing the padding to be used. The first character of this string will be used to fill all places needing padding. If this parameter is not passed, each padding byte will be a random character(0x00..0xFF)

remLength_andPad(array=>\@array) This function takes an array as proccessed by addLength_andPad and removes the padding and length from it. 'array' is a reference to the array to be processed. This is processed inline, the array you pass will be changed when the function returns.

largeNumToChar((size=>$size, number=>$number) This function takes a large number and converts it to a character string which it returns. 'size' is the number of bits the final character string should have. 'number' is the number to convert

EXPORT

None by default.

:all newKey() breakString() addLength_andPad()

SEE ALSO

perldoc Crypt::AoN perldoc Crypt::Random

AUTHOR

Timothy Zander, <timothy.zander@alum.rpi.edu>

COPYRIGHT AND LICENSE

Copyright (C) 2007 by Timothy Zander

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