© 2017 W.Ehrhardt Last update June 04, 2017
Home CRC/Hash Crypto Misc. Info Links Deutsch


Here you find a growing list of utility and standalone source codes other than CRC/Hash and Crypto: Util, PRNG, MPArith, AMath, DAMath, zlib, Delphi CRT.

The archive std.zip always contains the latest versions of the standard include file std.inc (compiler detection, standard definitions, options) and the common basic types unit BTypes.

Before downloading any software from this site please read this legal notice.


The archive util_2017-06-04.zip contains a collection of small units; in the past some of the units were available separately. Online help is available as Windows .hlp file or as a .tph for the BP7 IDE.

Last changes: Fix for debug mode range check error in Base2N.


Last changes:  D17/64-bit adjustments

The archive prng_2013-01-07.zip contains six fast pseudo random number generators with period lengths much greater than Pascal's random function:  taus88 and taus113 (Pierre L'Ecuyer), tt800 and mt19937 (Makoto Matsumoto et al, mt19937 is the famous Mersenne Twister), kiss123 (George Marsaglia), and xor4096 (Richard P. Brent). All are implemented with context records, therefore several independent generators can be used simultaneously, they are not cryptographically secure.

In addition there are three cryptographic generators: The units and test programs can be compiled with all current Pascal (TP5/5.5/6, BP7, VP 2.1, FPC 1.0/2.0-2.6/3.x) and Delphi (1..7/9-10/12/17-18) versions. Most test programs need the ministat and/or the hrtimer unit. All generators interface the following functions, a few special procedures are not listed here:

procedure generic_init(var ctx: generic_ctx; seed: longint);
  {-Init context from seed}

procedure generic_init0(var ctx: generic_ctx);
  {-Init context from randseed}

procedure generic_next(var ctx: generic_ctx);
  {-Next step of PRNG}

procedure generic_read(var ctx: generic_ctx; dest: pointer; len: longint);
  {-Read len bytes from the PRNG to dest}

function  generic_long(var ctx: generic_ctx): longint;
  {-Next random positive longint}

function  generic_dword(var ctx: generic_ctx): {$ifdef HAS_CARD32}cardinal{$else}longint{$endif};
  {-Next 32 bit random dword (cardinal or longint)}

function  generic_word(var ctx: generic_ctx): word;
  {-Next random word}

function  generic_double(var ctx: generic_ctx): double;
  {-Next random double [0..1) with 32 bit precision}

function  generic_double53(var ctx: generic_ctx): double;
  {-Next random double in [0..1) with 53 bit precision}

function  generic_selftest: boolean;
  {-Simple self-test of PRNG}
Table of properties (C/B: CPU cycles per byte, MB/s: million bytes per second. On 1.7 GHz Pentium 4 / Windows 98: BP7 = Borland Pascal 7 real mode with 386 BASM and D6 = Delphi 6; on Win7/64 Core i3-2350M: D18/64 = Delphi 18 64-bit. Note that isaac was compiled with {$define testing}):

BP7 BP7 D6 D6 D18/64 D18/64
Generator ctx size cycle length C/B MB/s C/B MB/s C/B MB/s
random (4) 2**32 79.0 21.4 7.5 226.0 5.8 399.1
taus88 16 2**88 79.0 21.5 8.0 211.9 10.8 213.5
taus113 20 2**113 85.0 20.0 8.0 211.9 13.5 170.0
kiss123 20 2**123 114.0 14.9 13.3 127.9 15.0 153.0
tt800 106 2**800 308.3 5.5 18.5 91.7 18.0 126.7
xor4096 522 2**4096 80.0 21.0 6.5 260.7 12.3 187.3
mt19937 2502 2**19937 227.4 7.4 8.3 204.5 12.6 181.5
aesr 290 2**128 211.2 8.0 28.4 59.7 60.2 38.1
salsar 202 2**70 108.3 15.7 15.4 110.3 31.1 73.8
isaac 2066 2**8295 122.0 13.9 9.0 189.3 12.8 178.9


mpa_2017-05-14.zip: This archive contains Pascal source for multi precision integer, rational, real, and complex arithmetic. The basic routines can be compiled with the usual Pascal versions that allow const parameters (tested with BP 7.0, VP 2.1, FPC 1.0/2.0/2.2/2.4/2.6/3x, and Delphi versions 1..7/9-10/12/17/18).

A separate introduction can be found on the mp_intro page; Windows and Borland Pascal help files are in the archive.

Last changes: Version 1.34.02 with the following new/changed functions: For a complete list with brief descriptions see the mp_intro function list.

There are test programs that verify the functions and the compilation. Demo programs are included for pi calculation, expression parsing and evaluation (including two interactive multi precision calculators), factorization based on Pollard's rho and p-1, Williams's p+1, and ECM methods, RSA attacks, etc.

My Pascal routines are based on many public resources (source code libraries, books, articles), links are given in the mp_intro references.


The archive amath_2016-10-23.zip contains units for accurate mathematical methods without using multi precision arithmetic. Please note that the high accuracy can only be achieved with the rmNearest rounding mode; it decreases if other modes are used. AMath is designed for the 80-bit extended data type, and therefore cannot be used with 64-bit code on 64-bit system (for these use the corresponding DAMath package). More information can be found on the separate introduction page.

The units and basic test programs can be compiled with the usual Pascal (TP5/5.5/6, BP7, VP 2.1, FPC 1.0/2.0/2.2/2.4/2.6/3x) and Delphi (1..7/9/10/12/17/18) versions (AMCmplx needs BP7 or newer). The test suites run without 'failure warnings about relative errors' on Intel CPUs on Win98, Win2000 (see log files), WinXP, and Win7. There may be some sporadic warnings with other processors or operating systems; normally, these are not AMath bugs but features of the CPU (and can be avoided by using slightly increased error levels).

Last changes: Unit AMath with the new accurate helper function sqrt1pmx; SpecFun/X with the new general Fibonacci function, general Chebyshev function the first kind, the nth "probabilists'" Hermite polynomial, CDF and ICDF for the limiting form of the Kolmogorov distribution function, nd the functional inverse of gamma; AMTools with the new function zbrenty for zeros of f(x)-y.


The archive damath_2017-05-14.zip contains units for double precision accurate mathematical methods without using multi precision arithmetic or assembler. The main purpose is to make the AMath functions available for 64-bit systems without Extended Precision or 387-FPU, but they can be used with 32-bit systems and on the Raspberry Pi 3. The source code can be compiled with the usual Pascal versions that allow const parameters (tested with BP 7.0, VP 2.1, FPC 1.0/2.0/2.2/2.4/2.6/3x, and Delphi versions 1..7/9-10/12/17/18).

The units assume IEEE-754 53-bit double precision (binary64) and rounding to nearest, and there are no rounding / precision control functions. The unit/function descriptions are not repeated here, see the corresponding AMath entries.

Last changes: The DAMath functions now support Raspberry Pi 3. There are no changes in the DAMath units, some error bounds in the test files have been adjusted for FPC/ARM with Raspberry Pi, results from FPC 3.0.2 are now included in the test suite.


zlibw114_2015-09-14.zip is my Pascal port of the zlib general purpose compression library version 1.1.4. It is based on PASZLIB 1.0 from Jacques Nomssi Nzali (corresponding to zlib 1.1.2). It includes official patches/changes up to v1.1.4 and some results from e-mail communication with Mark Adler.

Further changes are in gzio/minigzip, inffixed.inc, minizip, zdeflate (made code for $ifdef FASTEST usable), zlibh (z_assign as a work around for a nasty D6/7/9 bug), zutil, example (made test_sync code etc work).

Other features: 1) zlibex unit with custom deflate and inflate routines (incl. test program), it is used in the FZCA demo program.  2) Pascal port of the zpipe sample program. 3) Code improvements: make BUILDFIXED and assert work, bug fix in gzerror, etc.

Last changes:  Maintenance adjustments for Delphi 17+ and FPC 3.x

The library can be compiled with BP7 (DOS/Win/DPMI), Delphi 1-7/9-10/12/17-18, Virtual Pascal V2.1 and Free Pascal 1/2/3.x. The unit structure is slightly changed compared to PASZLIB: zlib (functions), zlibh (types/consts), gzio (gz functions) should be the only units used  by applications of zlib.

Please note:

Delphi CRT unit

During the development of the MPArith expression parser a number of deviations of Will de Witt's trusty Delphi CRT unit compared to BP7 were noticed and I decided to write a more compatible CRT unit.

Last changes:  Delphi 17 (XE3) adjustments

dcrt_2013-01-07.zip is a light version of Will DeWitt's code with several bug fixes (especially readkey, extended key codes etc). Will's 'unit was based heavily off of the Borland CBuilder 5 RTL'. Because of the unclear license status of Will's unit, my CRT source is not under zlib license. It is published with this disclaimer:

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. If you use this code, please credit me and keep the references to the other authors and sources.

Anyway, in this unit the code from Will/Borland is radically rewritten and rearranged. The guiding requirement was to make it almost BP7 compatible.

The basic idea for separate hardware/software sound support is from Rudy Velthuis' freeware console, but the implementation is different.

The supported keys for line editing are from BP7 (^A, ^H, ^D, ^F, ^M, ^S, ^Z), the paradigm shift from readkey to keypressed for doing the dirty work is from FP. The key codes / translations / functionalities were taken from the Phoenix BIOS book and a test program compiled with BP7.

Here are links to the referenced software programs.

There is still work to be done for some rare special extended keys, but this work is delayed to bugfixes or problem reports. Note: Although DCRT V1.32+ is compatible with D12+, the console output is still ANSI not Unicode.

Home CRC/Hash Crypto Misc. Info Links Deutsch