cryption 0.1.3

A D Library of encryption, decryption(3DES, AES, TEA, RSA...), encode, hash, and message digital signatures.


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

A D Library of encryption, decryption, encode, hash, and message digital signatures.

The same functional and fully compatible C++ project: https://github.com/shove70/crypt

AES:

import cryption.aes;

string key = "12341234123412341234123412341234";
ubyte[] message = cast(ubyte[])"123412341234123412341234123412341";

ubyte[] buffer = AESUtils.encrypt!AES128(message, key);
buffer = AESUtils.decrypt!AES128(buffer, key);

assert(message == buffer);

XTEA:

import cryption.tea.xtea;

int[4] key = [1, 2, 3, 4];
int rounds = 64;
ubyte[] message = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];

ubyte[] buffer = Xtea.encrypt(message, key, rounds);
buffer = Xtea.decrypt(buffer, key, rounds);

assert(message == buffer);

RSA:

import cryption.rsa;

RSAKeyPair keyPair = RSA.generateKeyPair(1024);
writeln(keyPair.privateKey);
writeln(keyPair.publicKey);

string data = "Data that needs to be encrypted";

ubyte[] en = RSA.encrypt(keyPair.privateKey, cast(ubyte[])data);
ubyte[] de = RSA.decrypt(keyPair.publicKey, en);
writeln(cast(string)de);

assert(cast(string)de = data);

For more examples, see unittest, Thanks.

Authors:
  • Shove
Dependencies:
none
Versions:
0.1.3 2018-Mar-05
0.1.2 2018-Jan-02
0.1.1 2017-Dec-17
0.1.0 2017-Nov-29
0.0.16 2017-Nov-06
Show all 21 versions
Download Stats:
  • 0 downloads today

  • 5 downloads this week

  • 17 downloads this month

  • 132 downloads total

Score:
0.8
Short URL:
cryption.dub.pm