© 2018 W.Ehrhardt Last update Nov. 27, 2018
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_2018-11-27.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: std.inc and unit Compvers support Delphi 26 / 10.3 'Rio' / VER330


Last changes:  New Well1024a generator by F. Panneton, P. L'Ecuyer and M. Matsumoto; rangel/w functions for random longint/word in range 0..range-1; pasrand unit with TP/Delphi compatible LC generator; new archive layout.

The archive prng_2018-01-01.zip contains seven 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), well1024a (Panneton, L'Ecuyer, Matsumoto) and xor4096 (Richard P. Brent). All are implemented with context records, therefore several independent generators can be used simultaneously, they are not cryptographically secure. A TP/Delphi compatible LC generator with the common functions and features can be found in unit pasrand.

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/25) versions. Most test programs need the ministat and/or the hrtimer unit. All generators interface the following common 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_rangew(var ctx: generic_ctx; range: word): word;
  {-Next random word in range 0..range-1}

function  generic_rangel(var ctx: generic_ctx; range: longint): longint;
  {-Next random longint in range 0..range-1}

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
pasrand 4 2**32 74.0 22.9 5.0 294.0 5.0 459.0
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
well1024a 134 2**1024 166.5 10.2 7.8 218.7 13.8 166.9
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


mparith_2018-11-27.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/25/26).

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.39.12 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_2018-11-27.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 following Pascal (BP7, VP 2.1, FPC 1.0/2.0/2.2/2.4/2.6/3x) and Delphi (2..7/9/10/12/17/18/25/26) versions. 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 functions: population covariance pcov/x and generic aliases Infinity, NegInfinity, NaN; Special Functions with derivatives of the zero order Kelvin functions; AMCmplx with the new functions: zeta, sinpi, Ei, E1, li; changed: agm(x,-x) = 0, nroot special cases n=1,2; fixed: expm1 and ln1p for small pure imaginary arguments.


The archive damath_2018-11-27.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/25/26).

The units assume IEEE-754 53-bit double precision (binary64) and rounding to nearest; since Aug. 2017 there is the separate unit DFPU with 64-bit/ARM compatible rounding / precision control functions based on the compiler's math unit. The unit/function descriptions are not repeated here, see the corresponding AMath entries.

Last changes: Unit DAMath with the new functions: population covariance pcov and generic aliases Infinity, NegInfinity, NaN; Special Functions with derivatives of the zero order Kelvin functions; DAMCmplx with the new functions: zeta, sinpi, Ei, E1, li; changed: agm(x,-x) = 0, nroot special cases n=1,2; fixed: expm1 and ln1p for small pure imaginary arguments.


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 25 Tokyo adjustments

dcrt_2017-11-29.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