© 2014 W.Ehrhardt Last update Dec. 07, 2014
Home CRC/Hash Crypto Misc. Info Links Deutsch

Miscellaneous

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.


Util

The archive util_2014-10-13.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: Compvers V0.30 supports Delphi 21 / XE7; standard include file std.inc V1.60

PRNG

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.2/2.4/2.6) and Delphi (1..7/9-10/12/17) 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: xor4096_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.8 GHz Pentium 4 / Windows 98, P7: Borland Pascal 7 real mode with 386 BASM; isaac was compiled with {$define testing}):

Generator ctx size cycle length C/B P7 MB/s P7 C/B D6 MB/s D6
random (4) 2**32 79.0 22.7 7.5 239.0
taus88 16 2**88 80.5 22.3 6.5 275.8
taus113 20 2**113 83.0 21.6 8.3 217.3
kiss123 20 2**123 96.0 18.7 11.8 152.6
tt800 106 2**800 230.8 7.8 18.1 99.2
xor4096 522 2**4096 82.5 21.7 5.8 311.8
mt19937 2502 2**19937 220.3 8.1 8.3 216.2
aesr 290 2**128 236.0 7.6 28.4 63.2
salsar 202 2**70 109.3 16.4 14.4 124.8
isaac 2066 2**8295 109.5 16.3 9.1 197.8


MPArith

mpa_2014-12-07.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, 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: Complex arithmetic-geometric mean, and more

Version 1.31.05 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.


AMath

The archive amath_2014-12-07.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) 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: AMath with small Bernoulli numbers; SpecFun/X with improved hyperg_1f1; AMCmplx with complex dilogarithm, complete elliptic integrals of the first kind.

DAMath

The archive damath_2014-12-07.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. 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, 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: DAMath with small Bernoulli numbers; SpecFunD with improved hyperg_1f1; DAMCmplx with complex dilogarithm, complete elliptic integrals of the first kind.

zlib

zlibw114_2009-07-25.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:  Delphi 2009 (D12) adjustments

The library can be compiled with BP7 (DOS/Win/DPMI), Delphi 1-7/9/10/12, Virtual Pascal V2.1 and Free Pascal 1.0/2.0/2.2. 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.

Note: the zlib routines should only be applied to files with sizes less that 2 GB (32 bit counters; Delphi eof bug and/or 32 bit filesize function).


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