On Thu, 01 May 2014 14:55:05 -0700, brad clawsie <b...@b7j0c.org> wrote:

Adam, this is very cool!

do you have any examples showing its use? In particular, examples highlighting D code using AES and SHA libs


You're welcome. There are no example yet. And the build script only supports Windows. Pull requests using *make tools most welcome.

A little walkthrough:

Build TitaniumCore, TitaniumD and TDI as static libraries. TitaniumCore and TitaniumD can be compiled with any C++ compiler and the availability of Boost Filesystem and ASIO. Although you'll have to specify the paths to Boost.

Once those libraries are built you'll need to pass all three of them to DMD along with your project.

Then the following code should work:

module test;
import std.stdio;
import Titanium.TDI; //Make sure to specify the correct search path with -I on the DMD commandline.

void main(string[] args)
        auto t = new TitaniumLibrary();
        //Hash Test Vectors
        string vec1 = "The quick brown fox jumps over the lazy dog";
        string vec2 = "The quick brown fox jumps over the lazy dog.";
        //Hash Testing
        writeln(HashSHA2(HashSize.Size256, vec1));
        SHA2 h = new SHA2(HashSize.Size256);
        AES c = new AES(CipherKeySize.Key128, CipherMode.GCM, 16);
        ubyte[] enc1 = c.Encrypt(cast(ubyte[])vec1.dup);
        string dec1 = cast(string)c.Decrypt(enc1);
        ubyte[] enc2 = c.Encrypt(cast(ubyte[])vec2.dup);
        string dec2 = cast(string)c.Decrypt(enc2);

The above sample shows SHA2 and AES-128/GCM.

Please submit bug reports and pull requests on GitHub if you run into any problems!

Adam Wilson
IRC: LightBender
Project Coordinator
The Aurora Project

Reply via email to