I am continuing to experiment with the coding patterns used in my numerics dll project and releasing TForge 0.60.
First of all TForge is a modern cryptographic library for Delphi and Lazarus/FPC (which I am currently working on) implemented as a set of runtime packages. The current release contains only one package (also named TForge); it is core package of the whole TForge project and is required by other packages (to be released later).
The purpose of the release is to introduce a new type – ByteArray; the type is an enhanced version of the standard RTL TBytes type. If you want to test the ByteArray you need to build tforge package; the release containes tforge packages for Delphi XE and Lazarus.
The release includes ByteArrayDemo console application which demonstrates functionality of the ByteArray type. For example, you can concatenate byte arrays:
var A1, A2: ByteArray; begin A1:= ByteArray(1); A2:= TBytes.Create(2, 3, 4); Writeln('A1 + A2 = ', (A1 + A2).ToString); // 1, 2, 3, 4
perform bitwise boolean operations (xor is most useful):
var A1, A2: ByteArray; begin A1:= ByteArray(1); A2:= TBytes.Create(2, 3, 4); Writeln('A1 xor A2 = ', (A1 xor A2).ToString); // 3 (= 1 xor 2, min array length used)
use fluent coding style (which appears to be very handy once one gets accustomed to it):
begin Writeln(ByteArray.FromText('ABCDEFGHIJ').Insert(3, ByteArray.FromText(' 123 ')).Reverse.ToText); // JIHGFED 321 CBA
and so on. It was fun to code ByteArray; I am using it more and more now as a TBytes replacement because of better usability.