This library implements some hash and cryptographic algorithms.

Dependents:   mBuinoBlinky PB_Emma_Ethernet SLOTrashHTTP Garagem ... more

This library implements the following algorithms :

  • RC4
  • AES (AES-128, AES-192, AES-256)
  • DES
  • Triple DES (EDE)
  • MD2
  • MD4
  • MD5
  • SHA-1
  • SHA-2 (SHA-224, SHA-256, SHA-384, SHA-512)

The hash algorithms have been optimized for the mbed and you should get decent performance. However, I did not optimize the ciphers. Also, I did not test extensively these algorithms : it should work but you may find some bugs. Block ciphers support two modes : ECB and CBC.

Warning

If you are using SHA-384 or SHA-512, be aware that it produces large binary files and the compilation (using the online compiler) takes much longer to execute. It may happen that the compiler stops because it timed-out. In this case, just compile again and it should work.

Computing hash

You can compute the hash of some data in two different ways. The first one is the easiest, each hash algorithm has a static method that takes some data and compute the hash from it.

Computing hash using method 1

#include "Crypto.h"
#include "mbed.h"

static const char msg[] = "mbed is great !";

int main()
{
    uint8_t hash[16];
    MD2::computeHash(hash, (uint8_t*)msg, strlen(msg));
    printf("hash: ");
    for(int i = 0; i < 16; ++i)
        printf("%02x", hash[i]);
    printf("\n");
    
    return 0;
}

The second one is slightly slower (around 2-3% slower) but it allows you to compute the hash of some data in several steps (by calling update method). This is the method you should use if you need to compute the hash from a large source and you don't have enough memory to store it in a single buffer.

Computing hash using method 2

#include "Crypto.h"
#include "mbed.h"

static const char msg[] = "mbed is great !";

int main()
{
    uint8_t hash[16];
    MD2 h;
    h.update((uint8_t*)msg, strlen(msg));
    h.finalize(hash);
    printf("hash: ");
    for(int i = 0; i < 16; ++i)
        printf("%02x", hash[i]);
    printf("\n");
    
    return 0;
}

TODO

  • optimize ciphers
  • add doc

Files at this revision

API Documentation at this revision

Comitter:
feb11
Date:
Sat Sep 14 18:21:32 2013 +0000
Parent:
6:19aa835f2bbb
Child:
8:a090264e9b2d
Commit message:
added DES (not tested yet)

Changed in this revision

AES.cpp Show diff for this revision Revisions of this file
AES.h Show diff for this revision Revisions of this file
Cipher.cpp Show diff for this revision Revisions of this file
Cipher.h Show diff for this revision Revisions of this file
DES.cpp Show diff for this revision Revisions of this file
DES.h Show diff for this revision Revisions of this file
HashAlgorithm.cpp Show diff for this revision Revisions of this file
HashAlgorithm.h Show diff for this revision Revisions of this file
MD2.cpp Show diff for this revision Revisions of this file
MD2.h Show diff for this revision Revisions of this file
MD5.cpp Show diff for this revision Revisions of this file
MD5.h Show diff for this revision Revisions of this file
RC4.cpp Show diff for this revision Revisions of this file
RC4.h Show diff for this revision Revisions of this file
SHA1.cpp Show diff for this revision Revisions of this file
SHA1.h Show diff for this revision Revisions of this file
SHA2.h Show diff for this revision Revisions of this file
SHA224.cpp Show diff for this revision Revisions of this file
SHA224.h Show diff for this revision Revisions of this file
SHA256.cpp Show diff for this revision Revisions of this file
SHA256.h Show diff for this revision Revisions of this file
SHA2_32.cpp Show diff for this revision Revisions of this file
SHA2_32.h Show diff for this revision Revisions of this file
SHA2_64.cpp Show diff for this revision Revisions of this file
SHA2_64.h Show diff for this revision Revisions of this file
SHA384.cpp Show diff for this revision Revisions of this file
SHA384.h Show diff for this revision Revisions of this file
SHA512.cpp Show diff for this revision Revisions of this file
SHA512.h Show diff for this revision Revisions of this file
cipher/AES.cpp Show annotated file Show diff for this revision Revisions of this file
cipher/AES.h Show annotated file Show diff for this revision Revisions of this file
cipher/Cipher.cpp Show annotated file Show diff for this revision Revisions of this file
cipher/Cipher.h Show annotated file Show diff for this revision Revisions of this file
cipher/DES.cpp Show annotated file Show diff for this revision Revisions of this file
cipher/DES.h Show annotated file Show diff for this revision Revisions of this file
cipher/RC4.cpp Show annotated file Show diff for this revision Revisions of this file
cipher/RC4.h Show annotated file Show diff for this revision Revisions of this file
cipher/TDES.h Show annotated file Show diff for this revision Revisions of this file
hash/HashAlgorithm.cpp Show annotated file Show diff for this revision Revisions of this file
hash/HashAlgorithm.h Show annotated file Show diff for this revision Revisions of this file
hash/MD2.cpp Show annotated file Show diff for this revision Revisions of this file
hash/MD2.h Show annotated file Show diff for this revision Revisions of this file
hash/MD5.cpp Show annotated file Show diff for this revision Revisions of this file
hash/MD5.h Show annotated file Show diff for this revision Revisions of this file
hash/SHA1.cpp Show annotated file Show diff for this revision Revisions of this file
hash/SHA1.h Show annotated file Show diff for this revision Revisions of this file
hash/SHA2.h Show annotated file Show diff for this revision Revisions of this file
hash/SHA224.cpp Show annotated file Show diff for this revision Revisions of this file
hash/SHA224.h Show annotated file Show diff for this revision Revisions of this file
hash/SHA256.cpp Show annotated file Show diff for this revision Revisions of this file
hash/SHA256.h Show annotated file Show diff for this revision Revisions of this file
hash/SHA2_32.cpp Show annotated file Show diff for this revision Revisions of this file
hash/SHA2_32.h Show annotated file Show diff for this revision Revisions of this file
hash/SHA2_64.cpp Show annotated file Show diff for this revision Revisions of this file
hash/SHA2_64.h Show annotated file Show diff for this revision Revisions of this file
hash/SHA384.cpp Show annotated file Show diff for this revision Revisions of this file
hash/SHA384.h Show annotated file Show diff for this revision Revisions of this file
hash/SHA512.cpp Show annotated file Show diff for this revision Revisions of this file
hash/SHA512.h Show annotated file Show diff for this revision Revisions of this file
--- a/AES.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,294 +0,0 @@
-#include "AES.h"
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-static const uint8_t sbox[] =
-{
-   0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
-   0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
-   0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
-   0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
-   0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84,
-   0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
-   0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8,
-   0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2,
-   0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
-   0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB,
-   0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79,
-   0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
-   0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A,
-   0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E,
-   0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
-   0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16
-};
-
-static const uint8_t inv_s[] = 
-{
-   0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB,
-   0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB,
-   0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E,
-   0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25,
-   0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92,
-   0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84,
-   0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06,
-   0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B,
-   0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73,
-   0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E,
-   0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B,
-   0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
-   0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F,
-   0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF,
-   0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
-   0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D
-};
-
-
-static const uint32_t rcon[10]=
-{
-    0x01000000, 0x02000000, 0x04000000, 0x08000000,
-    0x10000000, 0x20000000, 0x40000000, 0x80000000,
-    0x1B000000, 0x36000000
-};
-
-AES::AES(const AES_TYPE t, uint8_t *key):
-state()
-{
-    switch(t)
-    {
-        case AES_128:
-            nr = 10;
-            nk = 4;
-        break;
-        
-        case AES_192:
-            nr = 12;
-            nk = 6;
-        break;
-        
-        case AES_256:
-            nr = 14;
-            nk = 8;
-        break;
-    }
-    
-    keyExpansion(key);
-}
-
-void AES::keyExpansion(uint8_t *key)
-{
-    uint32_t temp;
-    int i = 0;
-    
-    while(i < nk)
-    {
-        w[i] = (key[4*i] << 24) + (key[4*i+1] << 16) + (key[4*i+2] << 8) + key[4*i+3];
-        i++;
-    }
-    i = nk;
-    while(i < 4*(nr+1))
-    {
-        temp = w[i-1];
-        if(i % nk == 0)
-        {
-            temp = rotWord(temp);
-            temp = subWord(temp);
-            temp ^= rcon[i/nk-1];
-        }
-        else if(nk > 6 && i % nk == 4)
-            temp = subWord(temp);
-        w[i] = w[i-nk] ^ temp;
-        i++;
-    }
-}
-
-uint32_t AES::rotWord(uint32_t w)
-{
-    return (w << 8) + (w >> 24);
-}
-
-uint32_t AES::invRotWord(uint32_t w)
-{
-    return (w >> 8) + (w << 24);
-}
-
-uint32_t AES::subWord(uint32_t w)
-{
-    uint32_t out = 0;
-    for(int i = 0; i < 4; ++i)
-    {
-        uint8_t temp = (w & 0xFF);
-        out |= (sbox[temp] << (8*i));
-        w = (w >> 8);
-    }
-    return out;
-}
-
-void AES::subBytes()
-{
-    for(int i = 0; i < 16; ++i)
-        state[i] = sbox[state[i]];
-}
-
-void AES::invSubBytes()
-{
-    for(int i = 0; i < 16; ++i)
-        state[i] = inv_s[state[i]];
-}
-
-void AES::shiftRows()
-{
-    for(int r = 0; r < 4; ++r)
-    {   
-        uint32_t temp = (state[r] << 24) + (state[r+4] << 16) + (state[r+8] << 8) + state[r+12];
-        int i = r;
-        while(i > 0)
-        {
-            temp = rotWord(temp);
-            --i;
-        }
-        state[r] = temp >> 24;
-        state[r+4] = temp >> 16;
-        state[r+8] = temp >> 8;
-        state[r+12] = temp;
-    }
-}
-
-void AES::invShiftRows()
-{
-    for(int r = 0; r < 4; ++r)
-    {
-        uint32_t temp = (state[r] << 24) + (state[r+4] << 16) + (state[r+8] << 8) + state[r+12];
-        int i = r;
-        while(i > 0)
-        {
-            temp = invRotWord(temp);
-            --i;
-        }
-        state[r] = temp >> 24;
-        state[r+4] = temp >> 16;
-        state[r+8] = temp >> 8;
-        state[r+12] = temp;
-    }
-}
-
-/* Multiply two numbers in the GF(2^8) finite field defined 
- * by the polynomial x^8 + x^4 + x^3 + x + 1 */
-uint8_t gmul(uint8_t a, uint8_t b) 
-{
-    uint8_t p = 0;
-    uint8_t counter;
-    uint8_t carry;
-    for (counter = 0; counter < 8; counter++) {
-        if (b & 1) 
-            p ^= a;
-        carry = (a & 0x80);
-        a <<= 1;
-        if (carry) 
-            a ^= 0x001B; /* what x^8 is modulo x^8 + x^4 + x^3 + x^2 + 1 */
-        b >>= 1;
-    }
-    return p;
-}
-
-void AES::mul(uint8_t *r) 
-{
-    uint8_t tmp[4];
-    memcpy(tmp, r, 4);
-    r[0] = gmul(tmp[0],2) ^ gmul(tmp[1],3) ^ tmp[2] ^ tmp[3];
-    r[1] = tmp[0] ^ gmul(tmp[1],2) ^ gmul(tmp[2],3) ^ tmp[3];
-    r[2] = tmp[0] ^ tmp[1] ^ gmul(tmp[2],2) ^ gmul(tmp[3],3);
-    r[3] = gmul(tmp[0],3) ^ tmp[1] ^ tmp[2] ^ gmul(tmp[3],2);
-}
-
-void AES::invMul(uint8_t *r)
-{
-    uint8_t tmp[4];
-    memcpy(tmp, r, 4);
-    r[0] = gmul(tmp[0],0x0e) ^ gmul(tmp[1],0x0b) ^ gmul(tmp[2],0x0d) ^ gmul(tmp[3],9);
-    r[1] = gmul(tmp[0],9) ^ gmul(tmp[1],0x0e) ^ gmul(tmp[2],0x0b) ^ gmul(tmp[3],0x0d);
-    r[2] = gmul(tmp[0],0x0d) ^ gmul(tmp[1],9) ^ gmul(tmp[2],0x0e) ^ gmul(tmp[3],0x0b);
-    r[3] = gmul(tmp[0],0x0b) ^ gmul(tmp[1],0x0d) ^ gmul(tmp[2],9) ^ gmul(tmp[3],0x0e);
-}
-
-void AES::mixColumns()
-{
-    for(int c = 0; c < 4; ++c)
-        mul(&state[4*c]);
-}
-
-void AES::invMixColumns()
-{
-    for(int c = 0; c < 4; ++c)
-        invMul(&state[4*c]);
-}
-
-void AES::addRoundKey(int round)
-{
-    for(int c = 0; c < 4; ++c)
-    {
-        uint32_t temp = (state[4*c] << 24) + (state[4*c+1] << 16) + (state[4*c+2] << 8) + state[4*c+3];
-        temp ^= w[round*4+c];
-        state[4*c] = temp >> 24;
-        state[4*c+1] = temp >> 16;
-        state[4*c+2] = temp >> 8;
-        state[4*c+3] = temp;
-    }
-}
-
-void AES::decryptBlock(uint8_t *out, uint8_t *in)
-{
-    memcpy(state,in,16);
-    
-    addRoundKey(nr);
-    
-    for(int round = nr-1; round > 0; --round)
-    {
-        invShiftRows();
-        invSubBytes();
-        addRoundKey(round);
-        invMixColumns();
-    }
-    invShiftRows();
-    invSubBytes();
-    addRoundKey(0);
-    
-    memcpy(out, state, 16);
-}
-
-void AES::encryptBlock(uint8_t *out, uint8_t *in)
-{
-    memcpy(state,in,16);
-    
-    addRoundKey(0);
-    
-    for(int round = 1; round < nr; ++round)
-    {
-        subBytes();
-        shiftRows();
-        mixColumns();
-        addRoundKey(round);
-    }
-    subBytes();
-    shiftRows();
-    addRoundKey(nr);
-    
-    memcpy(out, state, 16);
-}
-
-void AES::encrypt(uint8_t *out, uint8_t *in, uint32_t length)
-{
-    for(uint32_t i = 0; i < length; i+=16)
-        encryptBlock(&out[i], &in[i]);
-}
-
-void AES::decrypt(uint8_t *out, uint8_t *in, uint32_t length)
-{
-    for(uint32_t i = 0; i < length; i+=16)
-        decryptBlock(&out[i], &in[i]);
-}
-
-uint32_t AES::getBlockSize() const
-{
-    return 16;
-}
--- a/AES.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-#ifndef AES_H
-#define AES_H
-
-#include "Cipher.h"
-
-enum AES_TYPE
-{
-    AES_128 = 4,
-    AES_192 = 6,
-    AES_256 = 8
-};
-
-class AES : public Cipher
-{
-    public :
-    
-        AES(const AES_TYPE type, uint8_t *key);
-        
-        virtual void encrypt(uint8_t *out, uint8_t *in, uint32_t length);
-        virtual void decrypt(uint8_t *out, uint8_t *in, uint32_t length);
-        virtual uint32_t getBlockSize() const;
-        
-    private :
-    
-        void encryptBlock(uint8_t *out, uint8_t *in);
-        void decryptBlock(uint8_t *out, uint8_t *in);
-        
-        void keyExpansion(uint8_t *key);
-        uint32_t rotWord(uint32_t w);
-        uint32_t invRotWord(uint32_t w);        
-        uint32_t subWord(uint32_t w);
-        void subBytes();
-        void invSubBytes();
-        void shiftRows();
-        void invShiftRows();
-        void mul(uint8_t *r);
-        void invMul(uint8_t *r);
-        void mixColumns();
-        void invMixColumns();
-        void addRoundKey(int round);
-
-        uint8_t state[16];
-        uint32_t w[60];
-        uint8_t nr,nk;
-};
-
-#endif
--- a/Cipher.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-#include "Cipher.h"
-
-Cipher::~Cipher()
-{
-}
-
-
-CIPHER_TYPE Cipher::getType() const
-{
-    return getBlockSize() <= 1 ? STREAM_CIPHER : BLOCK_CIPHER;
-}
-
--- a/Cipher.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-#ifndef CIPHER_H
-#define CIPHER_H
-
-#include <stdint.h>
-
-enum CIPHER_TYPE
-{
-    STREAM_CIPHER,
-    BLOCK_CIPHER
-};
-
-class Cipher
-{
-    public :
-    
-        virtual ~Cipher();
-        
-        virtual void encrypt(uint8_t *out, uint8_t *in, uint32_t length) = 0;        
-        virtual void decrypt(uint8_t *out, uint8_t *in, uint32_t length) = 0;        
-        virtual uint32_t getBlockSize() const = 0;
-
-        CIPHER_TYPE getType() const;
-
-};
-
-
-#endif
--- a/DES.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-#include "DES.h"
-
-
-DES::DES(uint8_t *key):
-Cipher()
-{
-//    loadKey(key);
-}
-
-void DES::encrypt(uint8_t *out, uint8_t *in, uint32_t length)
-{
-
-}
-     
-void DES::decrypt(uint8_t *out, uint8_t *in, uint32_t length)
-{
-
-}
-
-uint32_t DES::getBlockSize() const
-{
-    return 8;
-}
-
-CIPHER_TYPE DES::getType() const
-{
-    return STREAM_CIPHER;
-}
--- a/DES.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-#ifndef DES_H
-#define DES_H
-
-#include "Cipher.h"
-
-
-class DES : public Cipher
-{
-    public :
-    
-        DES(uint8_t* key);
-        
-        virtual void encrypt(uint8_t *out, uint8_t *in, uint32_t length);        
-        virtual void decrypt(uint8_t *out, uint8_t *in, uint32_t length);        
-        virtual uint32_t getBlockSize() const;
-
-        CIPHER_TYPE getType() const;
-        
-    private :
-    
-        uint8_t keys[16][7];
-};
-
-#endif
--- a/HashAlgorithm.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#include "HashAlgorithm.h"
-
-HashAlgorithm::~HashAlgorithm()
-{
-}
--- a/HashAlgorithm.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-#ifndef HASH_ALGORITHM_H
-#define HASH_ALGORITHM_H
-
-#include <stdint.h>
-
-class HashAlgorithm
-{
-    public :
-    
-        virtual ~HashAlgorithm();
-        
-        virtual uint8_t outputSize() const = 0;
-        virtual void update(uint8_t *data, uint32_t length) = 0;
-        virtual void finalize(uint8_t *hash) = 0;
-};
-
-#endif
--- a/MD2.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,201 +0,0 @@
-/**
-    Implementation of MD2 as described here:
-    http://tools.ietf.org/html/rfc1319
-*/
-
-#include "MD2.h"
-#include <string.h>
-
-static const uint8_t s[] =
-{
-    0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, 
-    0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA, 
-    0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16, 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12, 
-    0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, 0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A, 
-    0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F, 0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21,
-    0x80, 0x7F, 0x5D, 0x9A, 0x5A, 0x90, 0x32, 0x27, 0x35, 0x3E, 0xCC, 0xE7, 0xBF, 0xF7, 0x97, 0x03, 
-    0xFF, 0x19, 0x30, 0xB3, 0x48, 0xA5, 0xB5, 0xD1, 0xD7, 0x5E, 0x92, 0x2A, 0xAC, 0x56, 0xAA, 0xC6, 
-    0x4F, 0xB8, 0x38, 0xD2, 0x96, 0xA4, 0x7D, 0xB6, 0x76, 0xFC, 0x6B, 0xE2, 0x9C, 0x74, 0x04, 0xF1, 
-    0x45, 0x9D, 0x70, 0x59, 0x64, 0x71, 0x87, 0x20, 0x86, 0x5B, 0xCF, 0x65, 0xE6, 0x2D, 0xA8, 0x02, 
-    0x1B, 0x60, 0x25, 0xAD, 0xAE, 0xB0, 0xB9, 0xF6, 0x1C, 0x46, 0x61, 0x69, 0x34, 0x40, 0x7E, 0x0F, 
-    0x55, 0x47, 0xA3, 0x23, 0xDD, 0x51, 0xAF, 0x3A, 0xC3, 0x5C, 0xF9, 0xCE, 0xBA, 0xC5, 0xEA, 0x26, 
-    0x2C, 0x53, 0x0D, 0x6E, 0x85, 0x28, 0x84, 0x09, 0xD3, 0xDF, 0xCD, 0xF4, 0x41, 0x81, 0x4D, 0x52, 
-    0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA, 0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A, 
-    0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D, 0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39, 
-    0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, 0xD0, 0xE4, 0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A, 
-    0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A, 0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14
-};
-
-
-MD2::MD2():
-HashAlgorithm(),
-bufferLength(0),
-l(0)
-{
-    memset(checksum, 0, 16);
-    memset(x, 0, 16);
-}
-
-uint8_t MD2::outputSize() const
-{
-    return 16;
-}
-
-void MD2::update(uint8_t *data, uint32_t length)
-{ 
-    if(bufferLength == 0)
-    {
-        while(length >= 16)
-        {
-            computeBlock(checksum, x, &l, data);
-            length -= 16;
-            data += 16;
-        }
-        bufferLength = length;
-        memcpy(buffer, data, length);
-    }
-    else if(length < 16-bufferLength)
-    {
-        memcpy(&buffer[bufferLength], data, length);
-        bufferLength += length;
-    }
-    else
-    {
-        int offset = 16-bufferLength;
-        memcpy(&buffer[bufferLength], data, offset);
-        computeBlock(checksum, x, &l, buffer);
-        data += offset;
-        length -= offset;
-        while(length >= 16)
-        {
-            computeBlock(checksum, x, &l, data);
-            data += 16;
-            length -= 16;
-        }
-        bufferLength = length;
-        memcpy(buffer, &data, length);
-    }
-    
-}
-
-void MD2::finalize(uint8_t *hash)
-{
-    // compute what's left data the buffer
-    int padding = 16 - bufferLength;
-    memset(&buffer[bufferLength], padding, padding);
-    computeBlock(checksum, x, &l, buffer);
-    computeBlock(checksum, x, &l, checksum);
-    memcpy(hash, x, 16);
-
-    uint32_t *x2 = (uint32_t*)x;
-    uint32_t *checksum2 = (uint32_t*)checksum;
-
-    // reset state
-    bufferLength = 0;
-    l = 0;
-    checksum2[0] = x2[0] = 0;
-    checksum2[1] = x2[1] = 0;
-    checksum2[2] = x2[2] = 0;
-    checksum2[3] = x2[3] = 0;
-}
-
-void MD2::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
-{
-    uint8_t x[48];
-    uint8_t checksum[16];
-    uint8_t buffer[16];
-    memset(x, 0, 16);
-    memset(checksum, 0, 16);
-    uint8_t l = 0;
-    while(length >= 16)
-    {
-        computeBlock(checksum, x, &l, data);
-        length -= 16;
-        data += 16;
-    }
-
-    memcpy(buffer, data, length);
-    uint8_t padding = 16-length;
-    memset(&buffer[length], padding, padding);
-    computeBlock(checksum, x, &l, buffer);
-    computeBlock(checksum,x, &l, checksum);
-    memcpy(hash, x, 16);
-}
-
-void MD2::computeBlock(uint8_t *checksum2, uint8_t *x2, uint8_t *l2, uint8_t *buffer2)
-{
-    if(checksum2 != buffer2)
-    {
-        for(int j = 0; j < 16; ++j)
-        {
-            uint8_t c = buffer2[j];
-            *l2 = (checksum2[j] ^= s[c^(*l2)]);
-        }
-    }
-    
-    uint32_t *x3 = (uint32_t*)x2;
-    uint32_t *buffer3 = (uint32_t*)buffer2;
-    
-    x3[4] = buffer3[0];
-    x3[5] = buffer3[1];
-    x3[6] = buffer3[2];
-    x3[7] = buffer3[3];
-    for(int j = 0; j < 4; ++j)
-        x3[8+j] = x3[4+j] ^ x3[j];
-    
-    uint8_t t = 0;
-    
-    for(int j = 0; j < 18; ++j)
-    {
-        t = (x2[0] ^= s[t]);
-        t = (x2[1] ^= s[t]);
-        t = (x2[2] ^= s[t]);
-        t = (x2[3] ^= s[t]);
-        t = (x2[4] ^= s[t]);
-        t = (x2[5] ^= s[t]);
-        t = (x2[6] ^= s[t]);
-        t = (x2[7] ^= s[t]);
-        t = (x2[8] ^= s[t]);
-        t = (x2[9] ^= s[t]);
-        t = (x2[10] ^= s[t]);
-        t = (x2[11] ^= s[t]);
-        t = (x2[12] ^= s[t]);
-        t = (x2[13] ^= s[t]);
-        t = (x2[14] ^= s[t]);
-        t = (x2[15] ^= s[t]);
-        t = (x2[16] ^= s[t]);
-        t = (x2[17] ^= s[t]);
-        t = (x2[18] ^= s[t]);
-        t = (x2[19] ^= s[t]);
-        t = (x2[20] ^= s[t]);
-        t = (x2[21] ^= s[t]);
-        t = (x2[22] ^= s[t]);
-        t = (x2[23] ^= s[t]);            
-        t = (x2[24] ^= s[t]);
-        t = (x2[25] ^= s[t]);
-        t = (x2[26] ^= s[t]);
-        t = (x2[27] ^= s[t]);
-        t = (x2[28] ^= s[t]);
-        t = (x2[29] ^= s[t]);
-        t = (x2[30] ^= s[t]);
-        t = (x2[31] ^= s[t]);
-        t = (x2[32] ^= s[t]);
-        t = (x2[33] ^= s[t]);
-        t = (x2[34] ^= s[t]);
-        t = (x2[35] ^= s[t]);
-        t = (x2[36] ^= s[t]);
-        t = (x2[37] ^= s[t]);
-        t = (x2[38] ^= s[t]);
-        t = (x2[39] ^= s[t]);
-        t = (x2[40] ^= s[t]);
-        t = (x2[41] ^= s[t]);
-        t = (x2[42] ^= s[t]);
-        t = (x2[43] ^= s[t]);
-        t = (x2[44] ^= s[t]);
-        t = (x2[45] ^= s[t]);
-        t = (x2[46] ^= s[t]);
-        t = (x2[47] ^= s[t]);            
-
-        t += j;
-    }
-}
\ No newline at end of file
--- a/MD2.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#ifndef MD2_H
-#define MD2_H
-
-#include "HashAlgorithm.h"
-
-class MD2 : public HashAlgorithm
-{
-    public :
-    
-        MD2();
-        
-        virtual uint8_t outputSize() const;
-        virtual void update(uint8_t *data, uint32_t length);
-        virtual void finalize(uint8_t *hash);
-        
-        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
-        
-    private :
-          
-        static void computeBlock(uint8_t *checksum, uint8_t *x, uint8_t *l2, uint8_t *buffer2);
-    
-        uint8_t bufferLength;
-        uint8_t l;
-        uint8_t buffer[16];
-        uint8_t checksum[16];
-        uint8_t x[48];
-};
-
-
-#endif
--- a/MD5.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,198 +0,0 @@
-/**
-    Implementation of MD5 as described here:
-    http://tools.ietf.org/html/rfc1321
-*/
-
-#include "MD5.h"
-#include <string.h>
-
-static const uint32_t A = 0x67452301;
-static const uint32_t B = 0xefcdab89;
-static const uint32_t C = 0x98badcfe;
-static const uint32_t D = 0x10325476;
-
-
-#define F(X,Y,Z) (((X) & (Y)) | ((~(X)) & (Z)))
-#define G(X,Y,Z) (((X) & (Z)) | ((Y) & (~(Z))))
-#define H(X,Y,Z) ((X) ^ (Y) ^ (Z))
-#define I(X,Y,Z) ((Y) ^ ((X) | (~(Z))))
-
-#define ROTL(W,N) (((W) << N) | ((W) >> (32-N)))
-
-#define ROUND1(a,b,c,d,x,s,t) \
-    a = ROTL(a + F(b,c,d) + x + t,s) + b; 
-
-#define ROUND2(a,b,c,d,x,s,t) \
-    a = ROTL(a + G(b,c,d) + x + t,s) + b; 
-
-#define ROUND3(a,b,c,d,x,s,t) \
-    a = ROTL(a + H(b,c,d) + x + t,s) + b; 
-
-#define ROUND4(a,b,c,d,x,s,t) \
-    a = ROTL(a + I(b,c,d) + x + t,s) + b; 
-
-
-    
-MD5::MD5():
-HashAlgorithm(),
-a(A),
-b(B),
-c(C),
-d(D),
-totalBufferLength(0),
-buffer(),
-bufferLength(0)
-{
-}
-
-uint8_t MD5::outputSize() const
-{
-    return 16;
-}
-
-void MD5::update(uint8_t *data, uint32_t length)
-{
-    if(length < 64-bufferLength)
-    {
-        memcpy(&buffer[bufferLength], data, length);
-        bufferLength += length;
-        totalBufferLength += length;
-        return;
-    }
-    int offset = 64-bufferLength;
-    memcpy(&buffer[bufferLength], data, offset);
-    computeRounds(&a, &b, &c, &d, buffer);
-    while(length-offset > 64)
-    {
-        memcpy(buffer, &data[offset], 64);
-        computeRounds(&a, &b, &c, &d, buffer);
-        offset += 64;
-    }
-    if(offset > length)
-        offset -= 64;
-    bufferLength = length - offset;
-    memcpy(buffer, &data[offset], bufferLength);
-    totalBufferLength += length;
-}
-
-void MD5::finalize(uint8_t *hash)
-{
-    uint32_t *hash2 = (uint32_t*)hash;
-    uint16_t padding;
-    if(totalBufferLength % 64 < 56)
-        padding = 56 - (totalBufferLength % 64);
-    else
-        padding = 56 + (64 - (totalBufferLength % 64));
-    buffer[bufferLength++] = 0x80;
-    padding--;
-    if(padding+bufferLength == 56)
-        memset(&buffer[bufferLength], 0, padding);
-    else
-    {
-        memset(&buffer[bufferLength], 0, 64-bufferLength);
-        computeRounds(&a, &b, &c, &d, buffer);
-        memset(buffer, 0, 56);
-    }
-    uint64_t lengthBit = totalBufferLength << 3;
-    uint32_t lengthBitLow = lengthBit;
-    uint32_t lengthBitHigh = lengthBit >> 32;
-    memcpy(&buffer[56], &lengthBitLow, 4);
-    memcpy(&buffer[60], &lengthBitHigh, 4);
-    computeRounds(&a, &b, &c, &d, buffer);
-
-    hash2[0] = a;
-    hash2[1] = b;
-    hash2[2] = c;
-    hash2[3] = d;
-    // reset state
-    a = A;
-    b = B;
-    c = C;
-    d = D;
-    totalBufferLength = 0;
-    bufferLength = 0;
-}
-
-
-void MD5::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
-{
-    uint32_t *hash2 = (uint32_t*)hash;
-    uint64_t lengthBit = length << 3;
-    uint16_t padding;
-    if(length % 64 < 56)
-        padding = 56 - (length % 64);
-    else
-        padding = 56 + (64 - (length % 64));
-        
-    uint32_t a = A, b = B, c = C, d = D;
-    while(length >= 64)
-    {
-        computeRounds(&a, &b, &c, &d, data);
-        data += 64;
-        length -= 64;
-    }
-    uint8_t buffer[64];
-    memcpy(buffer, data, length);
-    buffer[length++] = 0x80;
-    padding--;
-    if(padding+length == 56)
-        memset(&buffer[length], 0, padding);
-    else
-    {
-        memset(&buffer[length], 0, 64-length);
-        computeRounds(&a, &b, &c, &d, data);
-        memset(buffer, 0, 56);
-    }
-
-    uint32_t lengthBitLow = lengthBit;
-    uint32_t lengthBitHigh = lengthBit >> 32;
-    memcpy(&buffer[56], &lengthBitLow, 4);
-    memcpy(&buffer[60], &lengthBitHigh, 4);
-    
-    computeRounds(&a, &b, &c, &d, buffer);
-    
-    hash2[0] = a;
-    hash2[1] = b;
-    hash2[2] = c;
-    hash2[3] = d;
-}
-
-void MD5::computeRounds(uint32_t *a2, uint32_t *b2, uint32_t *c2, uint32_t *d2, uint8_t *buffer)
-{
-    uint32_t a = *a2, b = *b2, c = *c2, d = *d2;
-    uint32_t tmpA = a, tmpB = b, tmpC = c, tmpD = d;
-
-    uint32_t *x = (uint32_t*)buffer;
-       
-    // Round 1
-    ROUND1(a,b,c,d,x[0],7,0xd76aa478);     ROUND1(d,a,b,c,x[1],12,0xe8c7b756);    ROUND1(c,d,a,b,x[2],17,0x242070db);    ROUND1(b,c,d,a,x[3],22,0xc1bdceee);
-    ROUND1(a,b,c,d,x[4],7,0xf57c0faf);     ROUND1(d,a,b,c,x[5],12,0x4787c62a);    ROUND1(c,d,a,b,x[6],17,0xa8304613);    ROUND1(b,c,d,a,x[7],22,0xfd469501);
-    ROUND1(a,b,c,d,x[8],7,0x698098d8);     ROUND1(d,a,b,c,x[9],12,0x8b44f7af);    ROUND1(c,d,a,b,x[10],17,0xffff5bb1);   ROUND1(b,c,d,a,x[11],22,0x895cd7be);
-    ROUND1(a,b,c,d,x[12],7,0x6b901122);    ROUND1(d,a,b,c,x[13],12,0xfd987193);   ROUND1(c,d,a,b,x[14],17,0xa679438e);   ROUND1(b,c,d,a,x[15],22,0x49b40821);
-
-
-    // Round 2      
-    ROUND2(a,b,c,d,x[1],5,0xf61e2562);     ROUND2(d,a,b,c,x[6],9,0xc040b340);     ROUND2(c,d,a,b,x[11],14,0x265e5a51);   ROUND2(b,c,d,a,x[0],20,0xe9b6c7aa);
-    ROUND2(a,b,c,d,x[5],5,0xd62f105d);     ROUND2(d,a,b,c,x[10],9,0x02441453);    ROUND2(c,d,a,b,x[15],14,0xd8a1e681);   ROUND2(b,c,d,a,x[4],20,0xe7d3fbc8);
-    ROUND2(a,b,c,d,x[9],5,0x21e1cde6);     ROUND2(d,a,b,c,x[14],9,0xc33707d6);    ROUND2(c,d,a,b,x[3],14,0xf4d50d87);    ROUND2(b,c,d,a,x[8],20,0x455a14ed);
-    ROUND2(a,b,c,d,x[13],5,0xa9e3e905);    ROUND2(d,a,b,c,x[2],9,0xfcefa3f8);     ROUND2(c,d,a,b,x[7],14,0x676f02d9);    ROUND2(b,c,d,a,x[12],20,0x8d2a4c8a);
-    
-
-    // Round 3      
-    ROUND3(a,b,c,d,x[5],4,0xfffa3942);     ROUND3(d,a,b,c,x[8],11,0x8771f681);    ROUND3(c,d,a,b,x[11],16,0x6d9d6122);   ROUND3(b,c,d,a,x[14],23,0xfde5380c);
-    ROUND3(a,b,c,d,x[1],4,0xa4beea44);     ROUND3(d,a,b,c,x[4],11,0x4bdecfa9);    ROUND3(c,d,a,b,x[7],16,0xf6bb4b60);    ROUND3(b,c,d,a,x[10],23,0xbebfbc70);
-    ROUND3(a,b,c,d,x[13],4,0x289b7ec6);    ROUND3(d,a,b,c,x[0],11,0xeaa127fa);    ROUND3(c,d,a,b,x[3],16,0xd4ef3085);    ROUND3(b,c,d,a,x[6],23,0x04881d05);
-    ROUND3(a,b,c,d,x[9],4,0xd9d4d039);     ROUND3(d,a,b,c,x[12],11,0xe6db99e5);   ROUND3(c,d,a,b,x[15],16,0x1fa27cf8);   ROUND3(b,c,d,a,x[2],23,0xc4ac5665);
- 
- 
-    // Round 4
-    ROUND4(a,b,c,d,x[0],6,0xf4292244);     ROUND4(d,a,b,c,x[7],10,0x432aff97);    ROUND4(c,d,a,b,x[14],15,0xab9423a7);   ROUND4(b,c,d,a,x[5],21,0xfc93a039);
-    ROUND4(a,b,c,d,x[12],6,0x655b59c3);    ROUND4(d,a,b,c,x[3],10,0x8f0ccc92);    ROUND4(c,d,a,b,x[10],15,0xffeff47d);   ROUND4(b,c,d,a,x[1],21,0x85845dd1);
-    ROUND4(a,b,c,d,x[8],6,0x6fa87e4f);     ROUND4(d,a,b,c,x[15],10,0xfe2ce6e0);   ROUND4(c,d,a,b,x[6],15,0xa3014314);    ROUND4(b,c,d,a,x[13],21,0x4e0811a1);
-    ROUND4(a,b,c,d,x[4],6,0xf7537e82);     ROUND4(d,a,b,c,x[11],10,0xbd3af235);   ROUND4(c,d,a,b,x[2],15,0x2ad7d2bb);    ROUND4(b,c,d,a,x[9],21,0xeb86d391);
-    
-    *a2 = a + tmpA;
-    *b2 = b + tmpB;
-    *c2 = c + tmpC;
-    *d2 = d + tmpD;
-}
--- a/MD5.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#ifndef MD5_H
-#define MD5_H
-
-#include "HashAlgorithm.h"
-
-
-class MD5 : public HashAlgorithm
-{
-    public :
-    
-        MD5();
-        
-        virtual uint8_t outputSize() const;
-        virtual void update(uint8_t *data, uint32_t length);
-        virtual void finalize(uint8_t *hash);
-        
-        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
-        
-    private :
-    
-        static void computeRounds(uint32_t *a2, uint32_t *b2, uint32_t *c2, uint32_t *d2, uint8_t *buffer);
-        
-        uint32_t a,b,c,d;
-        uint32_t totalBufferLength;
-        uint8_t buffer[64];
-        uint8_t bufferLength;
-};
-
-#endif
--- a/RC4.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-#include "RC4.h"
-
-RC4::RC4(uint8_t *key, uint8_t keyLength):
-Cipher(),
-s(),
-i(0),
-j(0)
-{
-    for(int k = 0; k < 256; ++k)
-        s[k] = k;
-    int l = 0;
-    for(int k = 0; k < 256; ++k)
-    {
-        l = (l + s[k] + key[k % keyLength]) % 256;
-        uint8_t tmp = s[l];
-        s[l] = s[k];
-        s[k] = tmp;
-    } 
-}
-
-uint8_t RC4::encyptByte(uint8_t in)
-{
-    ++i;
-    j += s[i];
-    uint8_t tmp = s[i];
-    s[i] = s[j];
-    s[j] = tmp;
-    uint8_t c = s[(s[i]+s[j])%256];
-    return in^c;
-}
-
-void RC4::encrypt(uint8_t *out, uint8_t *in, uint32_t length)
-{
-    for(uint32_t l = 0; l < length; ++l)
-        out[l] = encyptByte(in[l]);
-}
-
-void RC4::decrypt(uint8_t *out, uint8_t *in, uint32_t length)    
-{
-    encrypt(out, in, length);
-}
-
-uint32_t RC4::getBlockSize() const
-{
-    return 1;
-}
--- a/RC4.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#ifndef RC4_H
-#define RC4_H
-
-#include "Cipher.h"
-
-class RC4 : public Cipher
-{
-    public :
-    
-        RC4(uint8_t *key, uint8_t keyLength);
-        
-        virtual void encrypt(uint8_t *out, uint8_t *in, uint32_t length);        
-        virtual void decrypt(uint8_t *out, uint8_t *in, uint32_t length);        
-        virtual uint32_t getBlockSize() const;
-        
-    private :
-    
-        uint8_t encyptByte(uint8_t in);
-        
-        uint8_t s[256];
-        uint8_t i,j;
-
-};
-
-#endif
--- a/SHA1.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,221 +0,0 @@
-/**
-    Implementation of SHA-1 as described here:
-    http://tools.ietf.org/html/rfc1319
-*/
-
-#include "SHA1.h"
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define F0(B,C,D) ((B & C) | ((~B) & D))
-#define F1(B,C,D) (B ^ C ^ D)
-#define F2(B,C,D) ((B & C) | (B & D) | (C & D))
-#define ROTL(W,N) (((W) << N) | ((W) >> (32-N)))
-                        
-static const uint32_t K0 = 0x5A827999;
-static const uint32_t K1 = 0x6ED9EBA1;
-static const uint32_t K2 = 0x8F1BBCDC;
-static const uint32_t K3 = 0xCA62C1D6;
-
-
-static const uint32_t H0 = 0x67452301;
-static const uint32_t H1 = 0xEFCDAB89;
-static const uint32_t H2 = 0x98BADCFE;
-static const uint32_t H3 = 0x10325476;
-static const uint32_t H4 = 0xC3D2E1F0;
-
-static const uint32_t MASK = 0xF;
-
-#define W(s) ( w[s] = ROTL(w[((s) + 13) & MASK] ^ w[((s) + 8) & MASK] ^ w[((s) + 2) & MASK] ^ w[s],1))
-
-#define R0(A,B,C,D,E,T) E += ROTL(A, 5) + F0(B, C, D) + w[T] + K0; \
-                        B = ROTL(B,30);
-#define R1(A,B,C,D,E,T) E += ROTL(A, 5) + F0(B, C, D) + W(T & MASK) + K0; \
-                        B = ROTL(B,30); 
-#define R2(A,B,C,D,E,T) E += ROTL(A, 5) + F1(B, C, D) + W(T & MASK) + K1; \
-                        B = ROTL(B,30); 
-#define R3(A,B,C,D,E,T) E += ROTL(A, 5) + F2(B, C, D) + W(T & MASK) + K2; \
-                        B = ROTL(B,30); 
-#define R4(A,B,C,D,E,T) E += ROTL(A, 5) + F1(B, C, D) + W(T & MASK) + K3; \
-                        B = ROTL(B,30); 
-
-                        
-SHA1::SHA1():
-HashAlgorithm(),
-h0(H0),
-h1(H1),
-h2(H2),
-h3(H3),
-h4(H4),
-totalBufferLength(0),
-buffer(),
-bufferLength(0)
-{
-}
-
-uint8_t SHA1::outputSize() const
-{
-    return 20;
-}
-
-void SHA1::update(uint8_t *data, uint32_t length)
-{
-    if(length < 64-bufferLength)
-    {
-        memcpy(&buffer[bufferLength], data, length);
-        bufferLength += length;
-        totalBufferLength += length;
-        return;
-    }
-    int offset = 64-bufferLength;
-    memcpy(&buffer[bufferLength], data, offset);
-    computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
-    while(length-offset > 64)
-    {
-        memcpy(buffer, &data[offset], 64);
-        computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
-        offset += 64;
-    }
-    if(offset > length)
-        offset -= 64;
-    bufferLength = length - offset;
-    memcpy(buffer, &data[offset], bufferLength);
-    totalBufferLength += length;
-}
-
-void SHA1::finalize(uint8_t *hash)
-{
-    uint32_t *hash2 = (uint32_t*)hash;
-    uint16_t padding;
-    if(totalBufferLength % 64 < 56)
-        padding = 56 - (totalBufferLength % 64);
-    else
-        padding = 56 + (64 - (totalBufferLength % 64));
-        
-    buffer[bufferLength++] = 0x80;
-    padding--;
-    if(padding+bufferLength == 56)
-        memset(&buffer[bufferLength], 0, padding);
-    else
-    {
-        memset(&buffer[bufferLength], 0, 64-bufferLength);
-        computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
-        memset(buffer, 0, 56);
-    }
-    
-    uint64_t lengthBit = totalBufferLength << 3;
-    uint32_t lengthBitLow = lengthBit;
-    uint32_t lengthBitHigh = lengthBit >> 32;
-    lengthBitLow = __rev(lengthBitLow);
-    lengthBitHigh = __rev(lengthBitHigh);
-    memcpy(&buffer[56], &lengthBitHigh, 4);
-    memcpy(&buffer[60], &lengthBitLow, 4);
-    computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
-    
-    hash2[0] = __rev(h0);
-    hash2[1] = __rev(h1);
-    hash2[2] = __rev(h2);
-    hash2[3] = __rev(h3);
-    hash2[4] = __rev(h4);
-    
-    // reset state
-    h0 = H0;
-    h1 = H1;
-    h2 = H2;
-    h3 = H3;
-    h4 = H4;
-    totalBufferLength = 0;
-    bufferLength = 0;
-}
-
-
-void SHA1::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
-{
-    uint32_t *hash2 = (uint32_t*)hash;
-    uint64_t lengthBit = length << 3;
-    uint32_t padding;
-    if(length % 64 < 56)
-        padding = 56 - (length % 64);
-    else
-        padding = 56 + (64 - (length % 64));
-        
-    uint32_t h0 = H0, h1 = H1, h2 = H2, h3 = H3, h4 = H4;
-    while(length >= 64)
-    {
-        computeBlock(&h0,&h1,&h2,&h3,&h4, data);
-        length -= 64;
-        data += 64;
-    }
-   
-    uint8_t buffer[64];
-    memcpy(buffer, data, length);
-    buffer[length++] = 0x80;
-    padding--;
-    if(padding+length+8 == 64)
-        memset(&buffer[length], 0, padding);
-    else
-    {
-        memset(&buffer[length], 0, 64-length);
-        computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
-        memset(buffer, 0, 56);
-    }
-
-    uint32_t lengthBitLow = lengthBit;
-    uint32_t lengthBitHigh = lengthBit >> 32;
-    lengthBitLow = __rev(lengthBitLow);
-    lengthBitHigh = __rev(lengthBitHigh);
-    memcpy(&buffer[60], &lengthBitLow, 4);
-    memcpy(&buffer[56], &lengthBitHigh, 4);
-    
-    computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
-
-    hash2[0] = __rev(h0);
-    hash2[1] = __rev(h1);
-    hash2[2] = __rev(h2);
-    hash2[3] = __rev(h3);
-    hash2[4] = __rev(h4);
-}
-
-void SHA1::computeBlock(uint32_t *h02, uint32_t *h12, uint32_t *h22, uint32_t *h32, uint32_t *h42, uint8_t *buffer)
-{
-    uint32_t *buffer2 = (uint32_t*)buffer;
-    uint32_t w[16];
-    for(int t = 0; t < 16; ++t)
-        w[t] = __rev(buffer2[t]);
-    
-    uint32_t a = *h02, b = *h12, c = *h22, d = *h32, e = *h42;
-    
-    R0(a,b,c,d,e, 0) R0(e,a,b,c,d, 1) R0(d,e,a,b,c, 2) R0(c,d,e,a,b, 3)
-    R0(b,c,d,e,a, 4) R0(a,b,c,d,e, 5) R0(e,a,b,c,d, 6) R0(d,e,a,b,c, 7)
-    R0(c,d,e,a,b, 8) R0(b,c,d,e,a, 9) R0(a,b,c,d,e,10) R0(e,a,b,c,d,11)
-    R0(d,e,a,b,c,12) R0(c,d,e,a,b,13) R0(b,c,d,e,a,14) R0(a,b,c,d,e,15)
-    R1(e,a,b,c,d,16) R1(d,e,a,b,c,17) R1(c,d,e,a,b,18) R1(b,c,d,e,a,19)    
-    
-    
-    R2(a,b,c,d,e,20) R2(e,a,b,c,d,21) R2(d,e,a,b,c,22) R2(c,d,e,a,b,23)
-    R2(b,c,d,e,a,24) R2(a,b,c,d,e,25) R2(e,a,b,c,d,26) R2(d,e,a,b,c,27)
-    R2(c,d,e,a,b,28) R2(b,c,d,e,a,29) R2(a,b,c,d,e,30) R2(e,a,b,c,d,31)
-    R2(d,e,a,b,c,32) R2(c,d,e,a,b,33) R2(b,c,d,e,a,34) R2(a,b,c,d,e,35)
-    R2(e,a,b,c,d,36) R2(d,e,a,b,c,37) R2(c,d,e,a,b,38) R2(b,c,d,e,a,39)    
-    
-    R3(a,b,c,d,e,40) R3(e,a,b,c,d,41) R3(d,e,a,b,c,42) R3(c,d,e,a,b,43)
-    R3(b,c,d,e,a,44) R3(a,b,c,d,e,45) R3(e,a,b,c,d,46) R3(d,e,a,b,c,47)
-    R3(c,d,e,a,b,48) R3(b,c,d,e,a,49) R3(a,b,c,d,e,50) R3(e,a,b,c,d,51)
-    R3(d,e,a,b,c,52) R3(c,d,e,a,b,53) R3(b,c,d,e,a,54) R3(a,b,c,d,e,55)
-    R3(e,a,b,c,d,56) R3(d,e,a,b,c,57) R3(c,d,e,a,b,58) R3(b,c,d,e,a,59)    
-    
-    
-    R4(a,b,c,d,e,60) R4(e,a,b,c,d,61) R4(d,e,a,b,c,62) R4(c,d,e,a,b,63)
-    R4(b,c,d,e,a,64) R4(a,b,c,d,e,65) R4(e,a,b,c,d,66) R4(d,e,a,b,c,67)
-    R4(c,d,e,a,b,68) R4(b,c,d,e,a,69) R4(a,b,c,d,e,70) R4(e,a,b,c,d,71)
-    R4(d,e,a,b,c,72) R4(c,d,e,a,b,73) R4(b,c,d,e,a,74) R4(a,b,c,d,e,75)
-    R4(e,a,b,c,d,76) R4(d,e,a,b,c,77) R4(c,d,e,a,b,78) R4(b,c,d,e,a,79)    
-        
-    *h02 += a;
-    *h12 += b;
-    *h22 += c;
-    *h32 += d;
-    *h42 += e;
-}
-
--- a/SHA1.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-#ifndef SHA1_H
-#define SHA1_H
-
-#include "HashAlgorithm.h"
-
-
-class SHA1 : public HashAlgorithm
-{
-    public :
-    
-        SHA1();
-
-        virtual uint8_t outputSize() const;        
-        virtual void update(uint8_t *data, uint32_t length);
-        virtual void finalize(uint8_t *hash);
-        
-        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
-        
-    private :
-        static void computeBlock(uint32_t *h02, uint32_t *h12, uint32_t *h22, uint32_t *h32, uint32_t *h42, uint8_t *buffer);
-    
-        uint32_t h0, h1, h2, h3, h4;
-        uint32_t totalBufferLength;
-        uint8_t buffer[64];
-        uint8_t bufferLength;       
-};
-
-#endif
--- a/SHA2.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#ifndef SHA2_H
-#define SHA2_H
-
-#include "SHA224.h"
-#include "SHA256.h"
-#include "SHA384.h"
-#include "SHA512.h"
-
-#endif
--- a/SHA224.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-#include "SHA224.h"
-
-
-SHA224::SHA224():
-HashAlgorithm(),
-algo(SHA_224)
-{
-}
-
-uint8_t SHA224::outputSize() const
-{
-    return 28;
-}
-
-void SHA224::update(uint8_t *data, uint32_t length)
-{
-    algo.update(data, length);
-}
-
-void SHA224::finalize(uint8_t *hash)
-{
-    algo.finalize(hash);
-}
-
-void SHA224::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
-{
-    SHA2_32::computeHash(SHA_224, hash, data, length);
-}
--- a/SHA224.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-#ifndef SHA2_224_H
-#define SHA2_224_H
-
-#include "HashAlgorithm.h"
-#include "SHA2_32.h"
-
-class SHA224 : public HashAlgorithm
-{
-    public :
-
-        SHA224();
-
-        virtual uint8_t outputSize() const;
-        virtual void update(uint8_t *data, uint32_t length);
-        virtual void finalize(uint8_t *hash);
-
-        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
-
-    private :
-    
-        SHA2_32 algo;
-};
-
-#endif
--- a/SHA256.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-#include "SHA256.h"
-
-
-SHA256::SHA256():
-HashAlgorithm(),
-algo(SHA_256)
-{
-}
-
-uint8_t SHA256::outputSize() const
-{
-    return 32;
-}
-
-void SHA256::update(uint8_t *data, uint32_t length)
-{
-    algo.update(data, length);
-}
-
-void SHA256::finalize(uint8_t *hash)
-{
-    algo.finalize(hash);
-}
-
-void SHA256::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
-{
-    SHA2_32::computeHash(SHA_256, hash, data, length);
-}
--- a/SHA256.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#ifndef SHA2_256_H
-#define SHA2_256_H
-
-#include "HashAlgorithm.h"
-#include "SHA2_32.h"
-
-
-class SHA256 : public HashAlgorithm
-{
-    public :
-
-        SHA256();
-        
-        virtual uint8_t outputSize() const;
-        virtual void update(uint8_t *data, uint32_t length);
-        virtual void finalize(uint8_t *hash);
-
-        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
-
-    private :
-    
-        SHA2_32 algo;
-};
-
-#endif
--- a/SHA2_32.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,314 +0,0 @@
-#include "SHA2_32.h"
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-
-static const uint8_t MASK = 0x0F;
-#define W(t) (w[(t)] = SSIG1(w[((t)+14)&MASK]) + w[((t)+9)&MASK] + SSIG0(w[((t)+1)&MASK]) + w[t])
-
-#define ROTL(W,N) (((W) << (N)) | ((W) >> (32-(N))))
-#define ROTR(W,N) (((W) >> (N)) | ((W) << (32-(N))))
-#define CH(X,Y,Z) (((X) & (Y)) ^ ((~(X)) & (Z)))
-#define MAJ(X,Y,Z) (((X) & (Y)) ^ ((X) & (Z)) ^ ((Y) & (Z)))
-#define BSIG0(X) (ROTR(X,2) ^ ROTR(X,13) ^ ROTR(X,22))
-#define BSIG1(X) (ROTR(X,6) ^ ROTR(X,11) ^ ROTR(X,25))
-#define SSIG0(X) (ROTR((X),7) ^ ROTR((X),18) ^ ((X) >> 3))
-#define SSIG1(X) (ROTR((X),17) ^ ROTR((X),19) ^ ((X) >> 10))
-#define R(A,B,C,D,E,F,G,H,T,K)  T1 = H + BSIG1(E) + CH(E,F,G) + K + (w[T] = __rev(buffer2[T])); \
-                              T2 = BSIG0(A) + MAJ(A,B,C); \
-                              D += T1; \
-                              H = T1 + T2;
-#define R2(A,B,C,D,E,F,G,H,T,K)  T1 = H + BSIG1(E) + CH(E,F,G) + K + W(T&MASK); \
-                              T2 = BSIG0(A) + MAJ(A,B,C); \
-                              D += T1; \
-                              H = T1 + T2;
-        
-static const uint32_t H[] =
-{
-    // SHA-224
-    0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
-    0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,
-    
-    // SHA-256      
-    0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
-    0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
-};
-
-SHA2_32::SHA2_32(SHA_32_TYPE t):
-type(t),
-totalBufferLength(0),
-bufferLength(0)
-{
-    switch(type)
-    {
-        case SHA_224:
-            h0 = H[0];
-            h1 = H[1];
-            h2 = H[2];
-            h3 = H[3];
-            h4 = H[4];
-            h5 = H[5];
-            h6 = H[6];
-            h7 = H[7];
-        break;
-        
-        case SHA_256:
-            h0 = H[8];
-            h1 = H[9];
-            h2 = H[10];
-            h3 = H[11];
-            h4 = H[12];
-            h5 = H[13];
-            h6 = H[14];
-            h7 = H[15];     
-        break;
-    }
-}
-
-void SHA2_32::update(uint8_t *data, uint32_t length)
-{
-    if(length < 64-bufferLength)
-    {
-        memcpy(&buffer[bufferLength], data, length);
-        bufferLength += length;
-        totalBufferLength += length;
-        return;
-    }
-    int offset = 64-bufferLength;
-    memcpy(&buffer[bufferLength], data, offset);
-    computeBlock(&h0,&h1,&h2,&h3,&h4,&h5,&h6,&h7,buffer);
-    while(length-offset > 64)
-    {
-        memcpy(buffer, &data[offset], 64);
-        computeBlock(&h0,&h1,&h2,&h3,&h4,&h5,&h6,&h7,buffer);
-        offset += 64;
-    }
-    if(offset > length)
-        offset -= 64;
-    bufferLength = length - offset;
-    memcpy(buffer, &data[offset], bufferLength);
-    totalBufferLength += length;
-}
-
-void SHA2_32::finalize(uint8_t *hash)
-{
-    uint32_t *hash2 = (uint32_t*)hash;
-    uint16_t padding;
-    if(totalBufferLength % 64 < 56)
-        padding = 56 - (totalBufferLength % 64);
-    else
-        padding = 56 + (64 - (totalBufferLength % 64));
-
-    buffer[bufferLength++] = 0x80;
-    padding--;
-    if(padding+bufferLength == 56)
-        memset(&buffer[bufferLength], 0, padding);
-    else
-    {
-        memset(&buffer[bufferLength], 0, 64-bufferLength);
-        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
-        memset(buffer, 0, 56);
-    }
-    
-    uint64_t lengthBit = totalBufferLength << 3;
-    uint32_t lengthBitLow = lengthBit;
-    uint32_t lengthBitHigh = lengthBit >> 32;
-    lengthBitLow = __rev(lengthBitLow);
-    lengthBitHigh = __rev(lengthBitHigh);
-    memcpy(&buffer[60], &lengthBitLow, 4);    
-    memcpy(&buffer[56], &lengthBitHigh, 4);    
-    computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
-
-    hash2[0] = __rev(h0);
-    hash2[1] = __rev(h1);
-    hash2[2] = __rev(h2);
-    hash2[3] = __rev(h3);
-    hash2[4] = __rev(h4);
-    hash2[5] = __rev(h5);
-    hash2[6] = __rev(h6);
-
-    
-    if(type == SHA_256)
-        hash2[7] = __rev(h7);
-    
-    // reset state
-    switch(type)
-    {
-        case SHA_224:
-            h0 = H[0];
-            h1 = H[1];
-            h2 = H[2];
-            h3 = H[3];
-            h4 = H[4];
-            h5 = H[5];
-            h6 = H[6];
-            h7 = H[7];
-        break;
-        
-        case SHA_256:
-            h0 = H[8];
-            h1 = H[9];
-            h2 = H[10];
-            h3 = H[11];
-            h4 = H[12];
-            h5 = H[13];
-            h6 = H[14];
-            h7 = H[15];     
-        break;
-    }
-    totalBufferLength = 0;
-    bufferLength = 0;
-}
-
-void SHA2_32::computeHash(SHA_32_TYPE type, uint8_t *hash, uint8_t *data, uint32_t length)
-{
-    uint32_t *hash2 = (uint32_t*)hash;
-    uint32_t h0 = H[type*8], h1 = H[type*8+1], h2 = H[type*8+2], h3 = H[type*8+3];
-    uint32_t h4 = H[type*8+4], h5 = H[type*8+5], h6 = H[type*8+6], h7 = H[type*8+7];
-    uint64_t lengthBit = length << 3;
-    uint16_t padding;
-    if(length % 64 < 56)
-        padding = 56 - (length % 64);
-    else
-        padding = 56 + (64 - (length % 64));
-        
-    while(length >= 64)
-    {
-        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, data);
-        length -= 64;
-        data += 64;
-    }
-    uint8_t buffer[64];
-    memcpy(buffer, data,length); 
-    buffer[length++] = 0x80;
-    padding--;
-    if(padding+length == 56)
-        memset(&buffer[length], 0, padding);
-    else
-    {
-        memset(&buffer[length], 0, 64-length);
-        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
-        memset(buffer, 0, 56);
-    }
-    
-    uint32_t lengthBitLow = lengthBit;
-    uint32_t lengthBitHigh = lengthBit >> 32;
-    lengthBitLow = __rev(lengthBitLow);
-    memcpy(&buffer[60], &lengthBitLow, 4);
-    lengthBitHigh = __rev(lengthBitHigh);
-    memcpy(&buffer[56], &lengthBitHigh, 4);    
-    computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
-
-    hash2[0] = __rev(h0);
-    hash2[1] = __rev(h1);
-    hash2[2] = __rev(h2);
-    hash2[3] = __rev(h3);
-    hash2[4] = __rev(h4);
-    hash2[5] = __rev(h5);
-    hash2[6] = __rev(h6);
-
-    
-    if(type == SHA_256)
-        hash2[7] = __rev(h7);
-}
-
-void SHA2_32::computeBlock(uint32_t *h02, 
-                        uint32_t *h12, 
-                        uint32_t *h22, 
-                        uint32_t *h32, 
-                        uint32_t *h42, 
-                        uint32_t *h52, 
-                        uint32_t *h62,
-                        uint32_t *h72,
-                        uint8_t *buffer)
-{
-    uint32_t w[16];
-    uint32_t *buffer2 = (uint32_t*)buffer;
-    uint32_t a = *h02, b = *h12, c = *h22, d = *h32, e = *h42, f = *h52, g = *h62, h = *h72;
-    uint32_t T1, T2;
-
-
-    R(a,b,c,d,e,f,g,h,0,0x428a2f98)
-    R(h,a,b,c,d,e,f,g,1,0x71374491)
-    R(g,h,a,b,c,d,e,f,2,0xb5c0fbcf)
-    R(f,g,h,a,b,c,d,e,3,0xe9b5dba5)
-    R(e,f,g,h,a,b,c,d,4,0x3956c25b)
-    R(d,e,f,g,h,a,b,c,5,0x59f111f1)
-    R(c,d,e,f,g,h,a,b,6,0x923f82a4)
-    R(b,c,d,e,f,g,h,a,7,0xab1c5ed5)
-
-    R(a,b,c,d,e,f,g,h,8,0xd807aa98)
-    R(h,a,b,c,d,e,f,g,9,0x12835b01)
-    R(g,h,a,b,c,d,e,f,10,0x243185be)
-    R(f,g,h,a,b,c,d,e,11,0x550c7dc3)
-    R(e,f,g,h,a,b,c,d,12,0x72be5d74)
-    R(d,e,f,g,h,a,b,c,13,0x80deb1fe)
-    R(c,d,e,f,g,h,a,b,14,0x9bdc06a7)
-    R(b,c,d,e,f,g,h,a,15,0xc19bf174)
-
-    R2(a,b,c,d,e,f,g,h,16,0xe49b69c1)
-    R2(h,a,b,c,d,e,f,g,17,0xefbe4786)
-    R2(g,h,a,b,c,d,e,f,18,0x0fc19dc6)
-    R2(f,g,h,a,b,c,d,e,19,0x240ca1cc)
-    R2(e,f,g,h,a,b,c,d,20,0x2de92c6f)
-    R2(d,e,f,g,h,a,b,c,21,0x4a7484aa)
-    R2(c,d,e,f,g,h,a,b,22,0x5cb0a9dc)
-    R2(b,c,d,e,f,g,h,a,23,0x76f988da)
-    
-    R2(a,b,c,d,e,f,g,h,24,0x983e5152)
-    R2(h,a,b,c,d,e,f,g,25,0xa831c66d)
-    R2(g,h,a,b,c,d,e,f,26,0xb00327c8)
-    R2(f,g,h,a,b,c,d,e,27,0xbf597fc7)
-    R2(e,f,g,h,a,b,c,d,28,0xc6e00bf3)
-    R2(d,e,f,g,h,a,b,c,29,0xd5a79147)
-    R2(c,d,e,f,g,h,a,b,30,0x06ca6351)
-    R2(b,c,d,e,f,g,h,a,31,0x14292967) 
-
-    R2(a,b,c,d,e,f,g,h,32,0x27b70a85)
-    R2(h,a,b,c,d,e,f,g,33,0x2e1b2138)
-    R2(g,h,a,b,c,d,e,f,34,0x4d2c6dfc)
-    R2(f,g,h,a,b,c,d,e,35,0x53380d13)
-    R2(e,f,g,h,a,b,c,d,36,0x650a7354)
-    R2(d,e,f,g,h,a,b,c,37,0x766a0abb)
-    R2(c,d,e,f,g,h,a,b,38,0x81c2c92e)
-    R2(b,c,d,e,f,g,h,a,39,0x92722c85)
-    
-    R2(a,b,c,d,e,f,g,h,40,0xa2bfe8a1)
-    R2(h,a,b,c,d,e,f,g,41,0xa81a664b)
-    R2(g,h,a,b,c,d,e,f,42,0xc24b8b70)
-    R2(f,g,h,a,b,c,d,e,43,0xc76c51a3)
-    R2(e,f,g,h,a,b,c,d,44,0xd192e819)
-    R2(d,e,f,g,h,a,b,c,45,0xd6990624)
-    R2(c,d,e,f,g,h,a,b,46,0xf40e3585)
-    R2(b,c,d,e,f,g,h,a,47,0x106aa070)
-    
-    R2(a,b,c,d,e,f,g,h,48,0x19a4c116)
-    R2(h,a,b,c,d,e,f,g,49,0x1e376c08)
-    R2(g,h,a,b,c,d,e,f,50,0x2748774c)
-    R2(f,g,h,a,b,c,d,e,51,0x34b0bcb5)
-    R2(e,f,g,h,a,b,c,d,52,0x391c0cb3)
-    R2(d,e,f,g,h,a,b,c,53,0x4ed8aa4a)
-    R2(c,d,e,f,g,h,a,b,54,0x5b9cca4f)
-    R2(b,c,d,e,f,g,h,a,55,0x682e6ff3)
-    
-    R2(a,b,c,d,e,f,g,h,56,0x748f82ee)
-    R2(h,a,b,c,d,e,f,g,57,0x78a5636f)
-    R2(g,h,a,b,c,d,e,f,58,0x84c87814)
-    R2(f,g,h,a,b,c,d,e,59,0x8cc70208)
-    R2(e,f,g,h,a,b,c,d,60,0x90befffa)
-    R2(d,e,f,g,h,a,b,c,61,0xa4506ceb)
-    R2(c,d,e,f,g,h,a,b,62,0xbef9a3f7)
-    R2(b,c,d,e,f,g,h,a,63,0xc67178f2)
-    
-    
-    *h02 += a;
-    *h12 += b;
-    *h22 += c;
-    *h32 += d;
-    *h42 += e;
-    *h52 += f;
-    *h62 += g;
-    *h72 += h;
-}
-
--- a/SHA2_32.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-#ifndef SHA2_32_H
-#define SHA2_32_H
-
-#include <stdint.h>
-
-enum SHA_32_TYPE
-{
-    SHA_224,
-    SHA_256
-};
-
-class SHA2_32
-{
-    public :
-    
-        SHA2_32(SHA_32_TYPE type);
-        void update(uint8_t *data, uint32_t length);
-        void finalize(uint8_t *digest);
-        
-        static void computeHash(SHA_32_TYPE type, uint8_t *digest, uint8_t *data, uint32_t length);
-        
-    private : 
-    
-        static void computeBlock(uint32_t *h02, 
-                                 uint32_t *h12, 
-                                 uint32_t *h22, 
-                                 uint32_t *h32, 
-                                 uint32_t *h42, 
-                                 uint32_t *h52, 
-                                 uint32_t *h62,
-                                 uint32_t *h72,
-                                 uint8_t *buffer);
-
-        SHA_32_TYPE type;
-        uint32_t h0, h1, h2, h3, h4, h5, h6, h7;
-        uint32_t totalBufferLength;
-        uint8_t buffer[64];
-        uint8_t bufferLength;   
-};
-
-#endif
--- a/SHA2_64.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,354 +0,0 @@
-#include "SHA2_64.h"
-#include <string.h>
-
-
-static const uint64_t H[] =
-{
-    // SHA-384
-    0xcbbb9d5dc1059ed8, 0x629a292a367cd507, 0x9159015a3070dd17, 0x152fecd8f70e5939,
-    0x67332667ffc00b31, 0x8eb44a8768581511, 0xdb0c2e0d64f98fa7, 0x47b5481dbefa4fa4,
-
-    // SHA-512
-    0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,
-    0x510e527fade682d1, 0x9b05688c2b3e6c1f, 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179
-};
-
-static uint64_t revWord(uint64_t w)
-{
-    return __rev(w >> 32) 
-         | ((uint64_t)(__rev(w)) << 32);
-}
-
-#define ROTL(W,N) (((W) << (N)) | ((W) >> (64-(N))))
-#define ROTR(W,N) (((W) >> (N)) | ((W) << (64-(N))))
-#define CH(X,Y,Z) (((X) & (Y)) ^ ((~(X)) & (Z)))
-#define MAJ(X,Y,Z) (((X) & (Y)) ^ ((X) & (Z)) ^ ((Y) & (Z)))
-#define BSIG0(X) (ROTR(X,28) ^ ROTR(X,34) ^ ROTR(X,39))
-#define BSIG1(X) (ROTR(X,14) ^ ROTR(X,18) ^ ROTR(X,41))
-#define SSIG0(X) (ROTR((X),1) ^ ROTR((X),8) ^ ((X) >> 7))
-#define SSIG1(X) (ROTR((X),19) ^ ROTR((X),61) ^ ((X) >> 6))
-
-#define R(A,B,C,D,E,F,G,H,K,T)  T1 = H + BSIG1(E) + CH(E,F,G) + K + w[T]; \
-                              T2 = BSIG0(A) + MAJ(A,B,C); \
-                              D += T1; \
-                              H = T1 + T2;    
-                          
-
-SHA2_64::SHA2_64(SHA2_64_TYPE t):
-type(t),
-totalBufferLength(0),
-bufferLength(0)
-{
-    switch(type)
-    {
-        case SHA_384:
-            h0 = H[0];
-            h1 = H[1];
-            h2 = H[2];
-            h3 = H[3];
-            h4 = H[4];
-            h5 = H[5];
-            h6 = H[6];
-            h7 = H[7];
-        break;
-        
-        case SHA_512:
-            h0 = H[8];
-            h1 = H[9];
-            h2 = H[10];
-            h3 = H[11];
-            h4 = H[12];
-            h5 = H[13];
-            h6 = H[14];
-            h7 = H[15];     
-        break;
-    }
-}
-
-void SHA2_64::update(uint8_t *data, uint32_t length)
-{
-    if(length < 128-bufferLength)
-    {
-        memcpy(&buffer[bufferLength], data, length);
-        bufferLength += length;
-        totalBufferLength += length;
-        return;
-    }
-    int offset = 128-bufferLength;
-    memcpy(&buffer[bufferLength], data, offset);
-    computeBlock(&h0,&h1,&h2,&h3,&h4,&h5,&h6,&h7,buffer);
-    while(length-offset > 128)
-    {
-        memcpy(buffer, &data[offset], 128);
-        computeBlock(&h0,&h1,&h2,&h3,&h4,&h5,&h6,&h7,buffer);
-        offset += 128;
-    }
-    if(offset > length)
-        offset -= 128;
-    bufferLength = length - offset;
-    memcpy(buffer, &data[offset], bufferLength);
-    totalBufferLength += length;
-}
-
-void SHA2_64::finalize(uint8_t *hash)
-{
-    uint64_t *hash2 = (uint64_t*)hash;
-    uint64_t lengthBit = totalBufferLength << 3;
-    uint32_t padding;
-    if(totalBufferLength % 128 < 112)
-        padding = 112 - (totalBufferLength % 128);
-    else
-        padding = 112 + (128 - (totalBufferLength % 128));
-
-    buffer[bufferLength++] = 0x80;
-    padding--;
-    if(padding+bufferLength == 112)
-        memset(&buffer[bufferLength], 0, padding);
-    else
-    {
-        memset(&buffer[bufferLength], 0, 64-bufferLength);
-        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
-        memset(buffer, 0, 112);
-    }
-    
-    lengthBit = revWord(lengthBit);
-    memcpy(&buffer[120], &lengthBit, 8);    
-    memset(&buffer[112], 0, 8);    
-    computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
-
-
-    hash2[0] = revWord(h0);
-    hash2[1] = revWord(h1);
-    hash2[2] = revWord(h2);
-    hash2[3] = revWord(h3);
-    hash2[4] = revWord(h4);
-    hash2[5] = revWord(h5);
-
-
-    if(type == SHA_512)
-    {
-        hash2[6] = revWord(h6);
-        hash2[7] = revWord(h7);
-    }
-    
-    // reset state
-    switch(type)
-    {
-        case SHA_384:
-            h0 = H[0];
-            h1 = H[1];
-            h2 = H[2];
-            h3 = H[3];
-            h4 = H[4];
-            h5 = H[5];
-            h6 = H[6];
-            h7 = H[7];
-        break;
-        
-        case SHA_512:
-            h0 = H[8];
-            h1 = H[9];
-            h2 = H[10];
-            h3 = H[11];
-            h4 = H[12];
-            h5 = H[13];
-            h6 = H[14];
-            h7 = H[15];     
-        break;
-    }
-    totalBufferLength = 0;
-    bufferLength = 0;
-}
-
-void SHA2_64::computeHash(SHA2_64_TYPE type, uint8_t *hash, uint8_t *data, uint32_t length)
-{
-    uint64_t *hash2 = (uint64_t*)hash;
-    uint64_t lengthBit = length * 8;
-    uint64_t h0 = H[type*8], h1 = H[type*8+1], h2 = H[type*8+2], h3 = H[type*8+3];
-    uint64_t h4 = H[type*8+4], h5 = H[type*8+5], h6 = H[type*8+6], h7 = H[type*8+7];
-    
-    int padding;
-    if(length % 128 < 112)
-        padding = 112 - (length % 128);
-    else
-        padding = 112 + (128 - (length % 128));
-        
-    while(length >= 128)
-    {
-        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, data);
-        data += 128;
-        length -= 128;
-    }
-    uint8_t buffer[128];
-    memcpy(buffer, data,length); 
-    buffer[length] = 0x80;
-    length++;
-    padding--;
-
-    if(padding+length == 112)
-        memset(&buffer[length], 0, padding);
-    else
-    {
-        memset(&buffer[length], 0, 128-length);
-        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
-        memset(buffer, 0, 112);
-    }
-    
-    lengthBit = revWord(lengthBit);
-    memset(&buffer[112], 0, 8); 
-    memcpy(&buffer[120], &lengthBit, 8);
-    computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
-
-    hash2[0] = revWord(h0);
-    hash2[1] = revWord(h1);
-    hash2[2] = revWord(h2);
-    hash2[3] = revWord(h3);
-    hash2[4] = revWord(h4);
-    hash2[5] = revWord(h5);
-
-
-    if(type == SHA_512)
-    {
-        hash2[6] = revWord(h6);
-        hash2[7] = revWord(h7);
-    }
-}
-
-void SHA2_64::computeBlock(uint64_t *h02, 
-                     uint64_t *h12, 
-                     uint64_t *h22, 
-                     uint64_t *h32, 
-                     uint64_t *h42, 
-                     uint64_t *h52, 
-                     uint64_t *h62,
-                     uint64_t *h72,
-                     uint8_t *buffer)
-{
-    uint64_t w[80];
-    uint64_t *buffer2 = (uint64_t*)buffer;
-
-    w[0] = revWord(buffer2[0]);
-    w[1] = revWord(buffer2[1]);
-    w[2] = revWord(buffer2[2]);
-    w[3] = revWord(buffer2[3]);
-    w[4] = revWord(buffer2[4]);
-    w[5] = revWord(buffer2[5]);
-    w[6] = revWord(buffer2[6]);
-    w[7] = revWord(buffer2[7]); 
-    w[8] = revWord(buffer2[8]);
-    w[9] = revWord(buffer2[9]);
-    w[10] = revWord(buffer2[10]);
-    w[11] = revWord(buffer2[11]);
-    w[12] = revWord(buffer2[12]);
-    w[13] = revWord(buffer2[13]);
-    w[14] = revWord(buffer2[14]);
-    w[15] = revWord(buffer2[15]);     
-    
-    for(int t = 16; t < 80; ++t)
-        w[t] = SSIG1(w[t-2]) + w[t-7] + SSIG0(w[t-15]) + w[t-16];
-    
-    uint64_t a = *h02, b = *h12, c = *h22, d = *h32, e = *h42, f = *h52, g = *h62, h = *h72;
-    uint64_t T1, T2;
-    
-
-    R(a,b,c,d,e,f,g,h,0x428a2f98d728ae22,0)
-    R(h,a,b,c,d,e,f,g,0x7137449123ef65cd,1)
-    R(g,h,a,b,c,d,e,f,0xb5c0fbcfec4d3b2f,2)
-    R(f,g,h,a,b,c,d,e,0xe9b5dba58189dbbc,3)
-    R(e,f,g,h,a,b,c,d,0x3956c25bf348b538,4)
-    R(d,e,f,g,h,a,b,c,0x59f111f1b605d019,5)
-    R(c,d,e,f,g,h,a,b,0x923f82a4af194f9b,6)
-    R(b,c,d,e,f,g,h,a,0xab1c5ed5da6d8118,7)
-
-    R(a,b,c,d,e,f,g,h,0xd807aa98a3030242,8)
-    R(h,a,b,c,d,e,f,g,0x12835b0145706fbe,9)
-    R(g,h,a,b,c,d,e,f,0x243185be4ee4b28c,10)
-    R(f,g,h,a,b,c,d,e,0x550c7dc3d5ffb4e2,11)
-    R(e,f,g,h,a,b,c,d,0x72be5d74f27b896f,12)
-    R(d,e,f,g,h,a,b,c,0x80deb1fe3b1696b1,13)
-    R(c,d,e,f,g,h,a,b,0x9bdc06a725c71235,14)
-    R(b,c,d,e,f,g,h,a,0xc19bf174cf692694,15)
-    
-    
-    R(a,b,c,d,e,f,g,h,0xe49b69c19ef14ad2,16)
-    R(h,a,b,c,d,e,f,g,0xefbe4786384f25e3,17)
-    R(g,h,a,b,c,d,e,f,0x0fc19dc68b8cd5b5,18)
-    R(f,g,h,a,b,c,d,e,0x240ca1cc77ac9c65,19)
-    R(e,f,g,h,a,b,c,d,0x2de92c6f592b0275,20)
-    R(d,e,f,g,h,a,b,c,0x4a7484aa6ea6e483,21)
-    R(c,d,e,f,g,h,a,b,0x5cb0a9dcbd41fbd4,22)
-    R(b,c,d,e,f,g,h,a,0x76f988da831153b5,23)
-    
-    R(a,b,c,d,e,f,g,h,0x983e5152ee66dfab,24)
-    R(h,a,b,c,d,e,f,g,0xa831c66d2db43210,25)
-    R(g,h,a,b,c,d,e,f,0xb00327c898fb213f,26)
-    R(f,g,h,a,b,c,d,e,0xbf597fc7beef0ee4,27)
-    R(e,f,g,h,a,b,c,d,0xc6e00bf33da88fc2,28)
-    R(d,e,f,g,h,a,b,c,0xd5a79147930aa725,29)
-    R(c,d,e,f,g,h,a,b,0x06ca6351e003826f,30)
-    R(b,c,d,e,f,g,h,a,0x142929670a0e6e70,31) 
-    
-    
-    R(a,b,c,d,e,f,g,h,0x27b70a8546d22ffc,32)
-    R(h,a,b,c,d,e,f,g,0x2e1b21385c26c926,33)
-    R(g,h,a,b,c,d,e,f,0x4d2c6dfc5ac42aed,34)
-    R(f,g,h,a,b,c,d,e,0x53380d139d95b3df,35)
-    R(e,f,g,h,a,b,c,d,0x650a73548baf63de,36)
-    R(d,e,f,g,h,a,b,c,0x766a0abb3c77b2a8,37)
-    R(c,d,e,f,g,h,a,b,0x81c2c92e47edaee6,38)
-    R(b,c,d,e,f,g,h,a,0x92722c851482353b,39)
-    
-    R(a,b,c,d,e,f,g,h,0xa2bfe8a14cf10364,40)
-    R(h,a,b,c,d,e,f,g,0xa81a664bbc423001,41)
-    R(g,h,a,b,c,d,e,f,0xc24b8b70d0f89791,42)
-    R(f,g,h,a,b,c,d,e,0xc76c51a30654be30,43)
-    R(e,f,g,h,a,b,c,d,0xd192e819d6ef5218,44)
-    R(d,e,f,g,h,a,b,c,0xd69906245565a910,45)
-    R(c,d,e,f,g,h,a,b,0xf40e35855771202a,46)
-    R(b,c,d,e,f,g,h,a,0x106aa07032bbd1b8,47)
-
-    R(a,b,c,d,e,f,g,h,0x19a4c116b8d2d0c8,48)
-    R(h,a,b,c,d,e,f,g,0x1e376c085141ab53,49)
-    R(g,h,a,b,c,d,e,f,0x2748774cdf8eeb99,50)
-    R(f,g,h,a,b,c,d,e,0x34b0bcb5e19b48a8,51)
-    R(e,f,g,h,a,b,c,d,0x391c0cb3c5c95a63,52)
-    R(d,e,f,g,h,a,b,c,0x4ed8aa4ae3418acb,53)
-    R(c,d,e,f,g,h,a,b,0x5b9cca4f7763e373,54)
-    R(b,c,d,e,f,g,h,a,0x682e6ff3d6b2b8a3,55)
-    
-    R(a,b,c,d,e,f,g,h,0x748f82ee5defb2fc,56)
-    R(h,a,b,c,d,e,f,g,0x78a5636f43172f60,57)
-    R(g,h,a,b,c,d,e,f,0x84c87814a1f0ab72,58)
-    R(f,g,h,a,b,c,d,e,0x8cc702081a6439ec,59)
-    R(e,f,g,h,a,b,c,d,0x90befffa23631e28,60)
-    R(d,e,f,g,h,a,b,c,0xa4506cebde82bde9,61)
-    R(c,d,e,f,g,h,a,b,0xbef9a3f7b2c67915,62)
-    R(b,c,d,e,f,g,h,a,0xc67178f2e372532b,63)
-
-    R(a,b,c,d,e,f,g,h,0xca273eceea26619c,64)
-    R(h,a,b,c,d,e,f,g,0xd186b8c721c0c207,65)
-    R(g,h,a,b,c,d,e,f,0xeada7dd6cde0eb1e,66)
-    R(f,g,h,a,b,c,d,e,0xf57d4f7fee6ed178,67)
-    R(e,f,g,h,a,b,c,d,0x06f067aa72176fba,68)
-    R(d,e,f,g,h,a,b,c,0x0a637dc5a2c898a6,69)
-    R(c,d,e,f,g,h,a,b,0x113f9804bef90dae,70)
-    R(b,c,d,e,f,g,h,a,0x1b710b35131c471b,71)
-
-    R(a,b,c,d,e,f,g,h,0x28db77f523047d84,72)
-    R(h,a,b,c,d,e,f,g,0x32caab7b40c72493,73)
-    R(g,h,a,b,c,d,e,f,0x3c9ebe0a15c9bebc,74)
-    R(f,g,h,a,b,c,d,e,0x431d67c49c100d4c,75)
-    R(e,f,g,h,a,b,c,d,0x4cc5d4becb3e42b6,76)
-    R(d,e,f,g,h,a,b,c,0x597f299cfc657e2a,77)
-    R(c,d,e,f,g,h,a,b,0x5fcb6fab3ad6faec,78)
-    R(b,c,d,e,f,g,h,a,0x6c44198c4a475817,79)
-            
-    *h02 += a;
-    *h12 += b;
-    *h22 += c;
-    *h32 += d;
-    *h42 += e;
-    *h52 += f;
-    *h62 += g;
-    *h72 += h;
-}
--- a/SHA2_64.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-#ifndef SHA2_64_H
-#define SHA2_64_H
-
-#include <stdint.h>
-
-enum SHA2_64_TYPE
-{
-    SHA_384,
-    SHA_512
-};
-
-class SHA2_64
-{
-    public :
-
-        SHA2_64(SHA2_64_TYPE type);
-        
-        void update(uint8_t *data, uint32_t length);
-        void finalize(uint8_t *hash);
-        
-        static void computeHash(SHA2_64_TYPE type, uint8_t *hash, uint8_t *data, uint32_t length);
-
-    private :
-    
-            static void computeBlock(uint64_t *h02, 
-                                 uint64_t *h12, 
-                                 uint64_t *h22, 
-                                 uint64_t *h32, 
-                                 uint64_t *h42, 
-                                 uint64_t *h52, 
-                                 uint64_t *h62,
-                                 uint64_t *h72,
-                                 uint8_t *buffer);
-                                 
-        SHA2_64_TYPE type;
-        uint64_t h0, h1, h2, h3, h4, h5, h6, h7;
-        uint32_t totalBufferLength;
-        uint8_t buffer[128];
-        uint8_t bufferLength;        
-};
-
-#endif
--- a/SHA384.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-#include "SHA384.h"
-
-
-SHA384::SHA384():
-HashAlgorithm(),
-algo(SHA_384)
-{
-}
-
-uint8_t SHA384::outputSize() const
-{
-    return 48;
-}
-
-void SHA384::update(uint8_t *data, uint32_t length)
-{
-    algo.update(data, length);
-}
-
-void SHA384::finalize(uint8_t *hash)
-{
-    algo.finalize(hash);
-}
-
-void SHA384::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
-{
-    SHA2_64::computeHash(SHA_384, hash, data, length);
-}
--- a/SHA384.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#ifndef SHA2_384_H
-#define SHA2_384_H
-
-#include "HashAlgorithm.h"
-#include "SHA2_64.h"
-
-
-class SHA384 : public HashAlgorithm
-{
-    public :
-
-        SHA384();
-        
-        virtual uint8_t outputSize() const;
-        virtual void update(uint8_t *data, uint32_t length);
-        virtual void finalize(uint8_t *hash);
-
-        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
-
-    private :
-    
-        SHA2_64 algo;
-};
-
-#endif
--- a/SHA512.cpp	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-#include "SHA512.h"
-
-
-SHA512::SHA512():
-HashAlgorithm(),
-algo(SHA_512)
-{
-}
-
-uint8_t SHA512::outputSize() const
-{
-    return 64;
-}
-
-void SHA512::update(uint8_t *data, uint32_t length)
-{
-    algo.update(data, length);
-}
-
-void SHA512::finalize(uint8_t *hash)
-{
-    algo.finalize(hash);
-}
-
-void SHA512::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
-{
-    SHA2_64::computeHash(SHA_512, hash, data, length);
-}
--- a/SHA512.h	Thu Sep 12 16:03:43 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#ifndef SHA2_512_H
-#define SHA2_512_H
-
-#include "HashAlgorithm.h"
-#include "SHA2_64.h"
-
-
-class SHA512 : public HashAlgorithm
-{
-    public :
-
-        SHA512();
-        
-        virtual uint8_t outputSize() const;
-        virtual void update(uint8_t *data, uint32_t length);
-        virtual void finalize(uint8_t *hash);
-
-        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
-
-    private :
-    
-        SHA2_64 algo;
-};
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cipher/AES.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,294 @@
+#include "AES.h"
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static const uint8_t sbox[] =
+{
+   0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
+   0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
+   0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
+   0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
+   0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84,
+   0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
+   0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8,
+   0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2,
+   0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
+   0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB,
+   0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79,
+   0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
+   0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A,
+   0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E,
+   0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
+   0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16
+};
+
+static const uint8_t inv_s[] = 
+{
+   0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB,
+   0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB,
+   0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E,
+   0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25,
+   0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92,
+   0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84,
+   0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06,
+   0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B,
+   0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73,
+   0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E,
+   0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B,
+   0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
+   0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F,
+   0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF,
+   0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
+   0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D
+};
+
+
+static const uint32_t rcon[10]=
+{
+    0x01000000, 0x02000000, 0x04000000, 0x08000000,
+    0x10000000, 0x20000000, 0x40000000, 0x80000000,
+    0x1B000000, 0x36000000
+};
+
+AES::AES(const AES_TYPE t, uint8_t *key):
+state()
+{
+    switch(t)
+    {
+        case AES_128:
+            nr = 10;
+            nk = 4;
+        break;
+        
+        case AES_192:
+            nr = 12;
+            nk = 6;
+        break;
+        
+        case AES_256:
+            nr = 14;
+            nk = 8;
+        break;
+    }
+    
+    keyExpansion(key);
+}
+
+void AES::keyExpansion(uint8_t *key)
+{
+    uint32_t temp;
+    int i = 0;
+    
+    while(i < nk)
+    {
+        w[i] = (key[4*i] << 24) + (key[4*i+1] << 16) + (key[4*i+2] << 8) + key[4*i+3];
+        i++;
+    }
+    i = nk;
+    while(i < 4*(nr+1))
+    {
+        temp = w[i-1];
+        if(i % nk == 0)
+        {
+            temp = rotWord(temp);
+            temp = subWord(temp);
+            temp ^= rcon[i/nk-1];
+        }
+        else if(nk > 6 && i % nk == 4)
+            temp = subWord(temp);
+        w[i] = w[i-nk] ^ temp;
+        i++;
+    }
+}
+
+uint32_t AES::rotWord(uint32_t w)
+{
+    return (w << 8) + (w >> 24);
+}
+
+uint32_t AES::invRotWord(uint32_t w)
+{
+    return (w >> 8) + (w << 24);
+}
+
+uint32_t AES::subWord(uint32_t w)
+{
+    uint32_t out = 0;
+    for(int i = 0; i < 4; ++i)
+    {
+        uint8_t temp = (w & 0xFF);
+        out |= (sbox[temp] << (8*i));
+        w = (w >> 8);
+    }
+    return out;
+}
+
+void AES::subBytes()
+{
+    for(int i = 0; i < 16; ++i)
+        state[i] = sbox[state[i]];
+}
+
+void AES::invSubBytes()
+{
+    for(int i = 0; i < 16; ++i)
+        state[i] = inv_s[state[i]];
+}
+
+void AES::shiftRows()
+{
+    for(int r = 0; r < 4; ++r)
+    {   
+        uint32_t temp = (state[r] << 24) + (state[r+4] << 16) + (state[r+8] << 8) + state[r+12];
+        int i = r;
+        while(i > 0)
+        {
+            temp = rotWord(temp);
+            --i;
+        }
+        state[r] = temp >> 24;
+        state[r+4] = temp >> 16;
+        state[r+8] = temp >> 8;
+        state[r+12] = temp;
+    }
+}
+
+void AES::invShiftRows()
+{
+    for(int r = 0; r < 4; ++r)
+    {
+        uint32_t temp = (state[r] << 24) + (state[r+4] << 16) + (state[r+8] << 8) + state[r+12];
+        int i = r;
+        while(i > 0)
+        {
+            temp = invRotWord(temp);
+            --i;
+        }
+        state[r] = temp >> 24;
+        state[r+4] = temp >> 16;
+        state[r+8] = temp >> 8;
+        state[r+12] = temp;
+    }
+}
+
+/* Multiply two numbers in the GF(2^8) finite field defined 
+ * by the polynomial x^8 + x^4 + x^3 + x + 1 */
+uint8_t gmul(uint8_t a, uint8_t b) 
+{
+    uint8_t p = 0;
+    uint8_t counter;
+    uint8_t carry;
+    for (counter = 0; counter < 8; counter++) {
+        if (b & 1) 
+            p ^= a;
+        carry = (a & 0x80);
+        a <<= 1;
+        if (carry) 
+            a ^= 0x001B; /* what x^8 is modulo x^8 + x^4 + x^3 + x^2 + 1 */
+        b >>= 1;
+    }
+    return p;
+}
+
+void AES::mul(uint8_t *r) 
+{
+    uint8_t tmp[4];
+    memcpy(tmp, r, 4);
+    r[0] = gmul(tmp[0],2) ^ gmul(tmp[1],3) ^ tmp[2] ^ tmp[3];
+    r[1] = tmp[0] ^ gmul(tmp[1],2) ^ gmul(tmp[2],3) ^ tmp[3];
+    r[2] = tmp[0] ^ tmp[1] ^ gmul(tmp[2],2) ^ gmul(tmp[3],3);
+    r[3] = gmul(tmp[0],3) ^ tmp[1] ^ tmp[2] ^ gmul(tmp[3],2);
+}
+
+void AES::invMul(uint8_t *r)
+{
+    uint8_t tmp[4];
+    memcpy(tmp, r, 4);
+    r[0] = gmul(tmp[0],0x0e) ^ gmul(tmp[1],0x0b) ^ gmul(tmp[2],0x0d) ^ gmul(tmp[3],9);
+    r[1] = gmul(tmp[0],9) ^ gmul(tmp[1],0x0e) ^ gmul(tmp[2],0x0b) ^ gmul(tmp[3],0x0d);
+    r[2] = gmul(tmp[0],0x0d) ^ gmul(tmp[1],9) ^ gmul(tmp[2],0x0e) ^ gmul(tmp[3],0x0b);
+    r[3] = gmul(tmp[0],0x0b) ^ gmul(tmp[1],0x0d) ^ gmul(tmp[2],9) ^ gmul(tmp[3],0x0e);
+}
+
+void AES::mixColumns()
+{
+    for(int c = 0; c < 4; ++c)
+        mul(&state[4*c]);
+}
+
+void AES::invMixColumns()
+{
+    for(int c = 0; c < 4; ++c)
+        invMul(&state[4*c]);
+}
+
+void AES::addRoundKey(int round)
+{
+    for(int c = 0; c < 4; ++c)
+    {
+        uint32_t temp = (state[4*c] << 24) + (state[4*c+1] << 16) + (state[4*c+2] << 8) + state[4*c+3];
+        temp ^= w[round*4+c];
+        state[4*c] = temp >> 24;
+        state[4*c+1] = temp >> 16;
+        state[4*c+2] = temp >> 8;
+        state[4*c+3] = temp;
+    }
+}
+
+void AES::decryptBlock(uint8_t *out, uint8_t *in)
+{
+    memcpy(state,in,16);
+    
+    addRoundKey(nr);
+    
+    for(int round = nr-1; round > 0; --round)
+    {
+        invShiftRows();
+        invSubBytes();
+        addRoundKey(round);
+        invMixColumns();
+    }
+    invShiftRows();
+    invSubBytes();
+    addRoundKey(0);
+    
+    memcpy(out, state, 16);
+}
+
+void AES::encryptBlock(uint8_t *out, uint8_t *in)
+{
+    memcpy(state,in,16);
+    
+    addRoundKey(0);
+    
+    for(int round = 1; round < nr; ++round)
+    {
+        subBytes();
+        shiftRows();
+        mixColumns();
+        addRoundKey(round);
+    }
+    subBytes();
+    shiftRows();
+    addRoundKey(nr);
+    
+    memcpy(out, state, 16);
+}
+
+void AES::encrypt(uint8_t *out, uint8_t *in, uint32_t length)
+{
+    for(uint32_t i = 0; i < length; i+=16)
+        encryptBlock(&out[i], &in[i]);
+}
+
+void AES::decrypt(uint8_t *out, uint8_t *in, uint32_t length)
+{
+    for(uint32_t i = 0; i < length; i+=16)
+        decryptBlock(&out[i], &in[i]);
+}
+
+uint32_t AES::getBlockSize() const
+{
+    return 16;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cipher/AES.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,47 @@
+#ifndef AES_H
+#define AES_H
+
+#include "Cipher.h"
+
+enum AES_TYPE
+{
+    AES_128 = 4,
+    AES_192 = 6,
+    AES_256 = 8
+};
+
+class AES : public Cipher
+{
+    public :
+    
+        AES(const AES_TYPE type, uint8_t *key);
+        
+        virtual void encrypt(uint8_t *out, uint8_t *in, uint32_t length);
+        virtual void decrypt(uint8_t *out, uint8_t *in, uint32_t length);
+        virtual uint32_t getBlockSize() const;
+        
+    private :
+    
+        void encryptBlock(uint8_t *out, uint8_t *in);
+        void decryptBlock(uint8_t *out, uint8_t *in);
+        
+        void keyExpansion(uint8_t *key);
+        uint32_t rotWord(uint32_t w);
+        uint32_t invRotWord(uint32_t w);        
+        uint32_t subWord(uint32_t w);
+        void subBytes();
+        void invSubBytes();
+        void shiftRows();
+        void invShiftRows();
+        void mul(uint8_t *r);
+        void invMul(uint8_t *r);
+        void mixColumns();
+        void invMixColumns();
+        void addRoundKey(int round);
+
+        uint8_t state[16];
+        uint32_t w[60];
+        uint8_t nr,nk;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cipher/Cipher.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,12 @@
+#include "Cipher.h"
+
+Cipher::~Cipher()
+{
+}
+
+
+CIPHER_TYPE Cipher::getType() const
+{
+    return getBlockSize() <= 1 ? STREAM_CIPHER : BLOCK_CIPHER;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cipher/Cipher.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,27 @@
+#ifndef CIPHER_H
+#define CIPHER_H
+
+#include <stdint.h>
+
+enum CIPHER_TYPE
+{
+    STREAM_CIPHER,
+    BLOCK_CIPHER
+};
+
+class Cipher
+{
+    public :
+    
+        virtual ~Cipher();
+        
+        virtual void encrypt(uint8_t *out, uint8_t *in, uint32_t length) = 0;        
+        virtual void decrypt(uint8_t *out, uint8_t *in, uint32_t length) = 0;        
+        virtual uint32_t getBlockSize() const = 0;
+
+        CIPHER_TYPE getType() const;
+
+};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cipher/DES.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,330 @@
+#include "DES.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static const uint8_t S1[] =
+{
+    14,  4, 13,  1,  2, 15, 11,  8,  3, 10,  6, 12,  5,  9,  0,  7,
+     0, 15,  7,  4, 14,  2, 13,  1, 10,  6, 12, 11,  9,  5,  3,  8,
+     4,  1, 14,  8, 13,  6,  2, 11, 15, 12,  9,  7,  3, 10,  5,  0, 
+    15, 12,  8,  2,  4,  9,  1,  7,  5, 11,  3, 14, 10,  0,  6, 13 
+};
+
+static const uint8_t S2[] =
+{
+    15,  1,  8, 14,  6, 11,  3,  4,  9,  7,  2, 13, 12,  0,  5, 10,
+     3, 13,  4,  7, 15,  2,  8, 14, 12,  0,  1, 10,  6,  9, 11,  5,
+     0, 14,  7, 11, 10,  4, 13,  1,  5,  8, 12,  6,  9,  3,  2, 15,
+    13,  8, 10,  1,  3, 15,  4,  2, 11,  6,  7, 12,  0,  5, 14,  9 
+};
+
+static const uint8_t S3[] = 
+{
+    10,  0,  9, 14,  6,  3, 15,  5,  1, 13, 12,  7, 11,  4,  2,  8,
+    13,  7,  0,  9,  3,  4,  6, 10,  2,  8,  5, 14, 12, 11, 15,  1,
+    13,  6,  4,  9,  8, 15,  3,  0, 11,  1,  2, 12,  5, 10, 14,  7,
+     1, 10, 13,  0,  6,  9,  8,  7,  4, 15, 14,  3, 11,  5,  2, 12 
+};
+
+static const uint8_t S4[] =
+{
+     7, 13, 14,  3,  0,  6,  9, 10,  1,  2,  8,  5, 11, 12,  4, 15,
+    13,  8, 11,  5,  6, 15,  0,  3,  4,  7,  2, 12,  1, 10, 14,  9,
+    10,  6,  9,  0, 12, 11,  7, 13, 15,  1,  3, 14,  5,  2,  8,  4,
+     3, 15,  0,  6, 10,  1, 13,  8,  9,  4,  5, 11, 12,  7,  2, 14 
+};
+
+static const uint8_t S5[] = 
+{
+     2, 12,  4,  1,  7, 10, 11,  6,  8,  5,  3, 15, 13,  0, 14,  9,
+    14, 11,  2, 12,  4,  7, 13,  1,  5,  0, 15, 10,  3,  9,  8,  6,
+     4,  2,  1, 11, 10, 13,  7,  8, 15,  9, 12,  5,  6,  3,  0, 14,
+    11,  8, 12,  7,  1, 14,  2, 13,  6, 15,  0,  9, 10,  4,  5,  3 
+};
+
+static const uint8_t S6[] =
+{
+    12,  1, 10, 15,  9,  2,  6,  8,  0, 13,  3,  4, 14,  7,  5, 11,
+    10, 15,  4,  2,  7, 12,  9,  5,  6,  1, 13, 14,  0, 11,  3,  8,
+     9, 14, 15,  5,  2,  8, 12,  3,  7,  0,  4, 10,  1, 13, 11,  6,
+     4,  3,  2, 12,  9,  5, 15, 10, 11, 14,  1,  7,  6,  0,  8, 13 
+};
+
+static const uint8_t S7[] =
+{
+     4, 11,  2, 14, 15,  0,  8, 13,  3, 12,  9,  7,  5, 10,  6,  1,
+    13,  0, 11,  7,  4,  9,  1, 10, 14,  3,  5, 12,  2, 15,  8,  6,
+     1,  4, 11, 13, 12,  3,  7, 14, 10, 15,  6,  8,  0,  5,  9,  2,
+     6, 11, 13,  8,  1,  4, 10,  7,  9,  5,  0, 15, 14,  2,  3, 12 
+};
+
+static const uint8_t S8[] =
+{
+    13,  2,  8,  4,  6, 15, 11,  1, 10,  9,  3, 14,  5,  0, 12,  7,
+     1, 15, 13,  8, 10,  3,  7,  4, 12,  5,  6, 11,  0, 14,  9,  2,
+     7, 11,  4,  1,  9, 12, 14,  2,  0,  6, 10, 13, 15,  3,  5,  8,
+     2,  1, 14,  7,  4, 10,  8, 13, 15, 12,  9,  0,  3,  5,  6, 11 
+};
+
+static void pc1(uint8_t *k, uint8_t *key)
+{
+    memset(k, 0, 7);
+    for(int i = 0; i < 8; ++i)
+    {
+        k[0] = (k[0] << 1) | (key[i] & 0x01);
+        k[1] = (k[1] << 1) | ((key[i] & 0x02) >> 1);
+        k[2] = (k[2] << 1) | ((key[i] & 0x04) >> 2);
+    }
+    for(int i = 0 ; i < 4; ++i)
+    {
+        k[3] = (k[3] << 1) | ((key[4+i] & 0x40) >> 6);
+        k[4] = (k[4] << 1) | ((key[4+i] & 0x20) >> 5);
+        k[5] = (k[5] << 1) | ((key[4+i] & 0x10) >> 4);
+        k[6] = (k[6] << 1) | ((key[i] & 0x08) >> 3);
+    }
+    for(int i = 0 ; i < 4; ++i)
+    {
+        k[3] = (k[3] << 1) | ((key[4+i] & 0x08) >> 3);
+        k[4] = (k[4] << 1) | ((key[i] & 0x40) >> 6);
+        k[5] = (k[5] << 1) | ((key[i] & 0x20) >> 5);
+        k[6] = (k[6] << 1) | ((key[i] & 0x10) >> 4);
+    }       
+}
+
+static void leftShift(uint8_t *k)
+{
+    uint8_t tmp = k[0] & 0x01, tmp2 = k[3] & 0x10;
+    k[0] = (k[0] >> 1) | ((k[1] & 0x01) << 7);
+    k[1] = (k[1] >> 1) | ((k[2] & 0x01) << 7);
+    k[2] = (k[2] >> 1) | ((k[3] & 0x01) << 7);
+    
+    k[3] = ((k[3] & 0x0E) >> 1) | (tmp << 3) | ((k[3] & 0xE0) >> 1) | ((k[4] & 0x01) << 7);
+    
+    k[4] = (k[4] >> 1) | ((k[5] & 0x01) << 7);
+    k[5] = (k[5] >> 1) | ((k[6] & 0x01) << 7);
+    k[6] = (k[6] >> 1) | (tmp2 << 3);
+        
+}
+
+void pc2(uint8_t *subKey, uint8_t *k)
+{
+    subKey[0] = ((k[1] & 0x20) >> 5) | ((k[2] & 0x01) << 1) | (k[1] & 0x04) | ((k[2] & 0x80) >> 4) | ((k[0] & 0x01) << 4) | ((k[0] & 0x10) << 1) | ((k[0] & 0x04) << 4) | ((k[3] & 0x08) << 4);
+    subKey[1] = ((k[1] & 0x40) >> 6) | ((k[0] & 0x20) >> 4) | ((k[2] & 0x10) >> 2) | ((k[1] & 0x02) << 2) | ((k[2] & 0x40) >> 2) | ((k[2] & 0x04) << 3) | ((k[1] & 0x08) << 3) | ((k[0] & 0x08) << 4);
+    subKey[2] = ((k[3] & 0x02) >> 1) | ((k[0] & 0x80) >> 6) | ((k[1] & 0x80) >> 5) | ((k[0] & 0x40) >> 3) | ((k[3] & 0x04) << 2) | ((k[2] & 0x08) << 2) | ((k[1] & 0x10) << 2) | ((k[0] & 0x02) << 6);
+    subKey[3] = (k[5] & 0x01) | ((k[6] & 0x08) >> 2) | ((k[3] & 0x40) >> 4) | ((k[4] & 0x10) >> 1) | ((k[5] & 0x40) >> 2) | ((k[6] & 0x40) >> 1) | ((k[3] & 0x20) << 1) | (k[4] & 0x80);
+    subKey[4] = ((k[6] & 0x04) >> 2) | ((k[5] & 0x10) >> 3) | ((k[4] & 0x01) << 2) | ((k[5] & 0x80) >> 4) | ((k[5] & 0x08) << 1) | ((k[6] & 0x01) << 5) | (k[4] & 0x40) | (k[6] & 0x80);
+    subKey[5] = ((k[4] & 0x02) >> 1) | ((k[6] & 0x10) >> 3) | ((k[5] & 0x20) >> 3) | ((k[5] & 0x02) << 2) | ((k[6] & 0x02) << 3) | ((k[4] & 0x08) << 2) | ((k[3] & 0x10) << 2) | (k[3] & 0x80);
+}
+
+
+static void initialPermutation(uint8_t *in)
+{
+    uint8_t tmp[8];
+    memcpy(tmp, in, 8);
+    for(int i = 0; i < 8; ++i)
+    {
+        tmp[4] = (tmp[4] << 1) | (in[i] & 0x01);
+        tmp[5] = (tmp[5] << 1) | ((in[i] & 0x04) >> 2);
+        tmp[6] = (tmp[6] << 1) | ((in[i] & 0x10) >> 4);
+        tmp[7] = (tmp[7] << 1) | ((in[i] & 0x40) >> 6);
+        
+        tmp[0] = (tmp[0] << 1) | ((in[i] & 0x02) >> 1);
+        tmp[1] = (tmp[1] << 1) | ((in[i] & 0x08) >> 3);
+        tmp[2] = (tmp[2] << 1) | ((in[i] & 0x20) >> 5);
+        tmp[3] = (tmp[3] << 1) | ((in[i] & 0x80) >> 7); 
+    }
+    
+    memcpy(in, tmp, 8);
+}
+
+static void invInitialPermutation(uint8_t *out)
+{
+    uint8_t tmp[8];
+    memcpy(tmp, out , 8);
+    for(int i = 3; i >= 0; --i)
+    {
+        out[0] = (out[0] << 2) | ((tmp[4+i] & 0x80) >> 7) | ((tmp[i] & 0x80) >> 6); 
+        out[1] = (out[1] << 2) | ((tmp[4+i] & 0x40) >> 6) | ((tmp[i] & 0x40) >> 5);
+        out[2] = (out[2] << 2) | ((tmp[4+i] & 0x20) >> 5) | ((tmp[i] & 0x20) >> 4);
+        out[3] = (out[3] << 2) | ((tmp[4+i] & 0x10) >> 4) | ((tmp[i] & 0x10) >> 3);
+        out[4] = (out[4] << 2) | ((tmp[4+i] & 0x08) >> 3) | ((tmp[i] & 0x08) >> 2);
+        out[5] = (out[5] << 2) | ((tmp[4+i] & 0x04) >> 2) | ((tmp[i] & 0x04) >> 1);
+        out[6] = (out[6] << 2) | ((tmp[4+i] & 0x02) >> 1) | (tmp[i] & 0x02);
+        out[7] = (out[7] << 2) | (tmp[4+i] & 0x01)      | ((tmp[i] & 0x01) << 1);
+    }
+}
+
+static void expand(uint8_t *e, uint8_t *r)
+{
+    
+    e[0] = ((r[3] & 0x80) >> 7) | ((r[0] & 0x1F) << 1) | ((r[0] & 0x18) << 3);
+    e[1] = ((r[0] & 0xE0) >> 5) | ((r[1] & 0x01) << 3) | ((r[0] & 0x80) >> 3) | ((r[1] & 0x07) << 5);
+    e[2] = ((r[1] & 0x18) >> 3) | ((r[1] & 0xF8) >> 1) | ((r[2] & 0x01) << 7);                
+    e[3] = ((r[1] & 0x80) >> 7) | ((r[2] & 0x1F) << 1) | ((r[2] & 0x18) << 3);
+    e[4] = ((r[2] & 0xE0) >> 5) | ((r[3] & 0x01) << 3) | ((r[2] & 0x80) >> 3) | ((r[3] & 0x07) << 5);
+    e[5] = ((r[3] & 0x18) >> 3) | ((r[3] & 0xF8) >> 1) | ((r[0] & 0x01) << 7);
+    
+}
+
+static void permutation(uint8_t *r)
+{
+    uint8_t buffer[4];
+    
+    buffer[0] = ((r[1] & 0x80) >> 7) | ((r[0] & 0x40) >> 5) | ((r[2] & 0x08) >> 1) | ((r[2] & 0x10) >> 1) | (r[3] & 0x10) | ((r[1] & 0x08) << 2) | ((r[3] & 0x08) << 3) | ((r[2] & 0x01) << 7);
+    buffer[1] = (r[0] & 0x01) | ((r[1] & 0x40) >> 5) | ((r[2] & 0x40) >> 4) | ((r[3] & 0x02) << 2) | (r[0] & 0x10) | ((r[2] & 0x02) << 4) | (r[3] & 0x40) | ((r[1] & 0x02) << 6);
+    buffer[2] = ((r[0] & 0x02) >> 1) | ((r[0] & 0x80) >> 6) | ((r[2] & 0x80) >> 5) | ((r[1] & 0x20) >> 2) | ((r[3] & 0x80) >> 3) | ((r[3] & 0x04) << 3) | ((r[0] & 0x04) << 4) | ((r[1] & 0x01) << 7);
+    buffer[3] = ((r[2] & 0x04) >> 2) |  ((r[1] & 0x10) >> 3) | ((r[3] & 0x20) >> 3) | ((r[0] & 0x20) >> 2) | ((r[2] & 0x20) >> 1) | ((r[1] & 0x04) << 3) | ((r[0] & 0x08) << 3) | ((r[3] & 0x01) << 7);
+    
+    memcpy(r, buffer,4);
+}
+
+static void substitute(uint8_t *r, uint8_t *e)
+{
+    int index = ((e[0] & 0x01) << 5) | ((e[0] & 0x02) << 2) | (e[0] & 0x04)  | ((e[0] & 0x08) >> 2) | ((e[0] & 0x10) >> 4) | ((e[0] & 0x20) >> 1);
+    int index2 = ((e[0] & 0x40) >> 1) | ((e[0] & 0x80) >> 4) | ((e[1] & 0x01) << 2) | (e[1] & 0x02) | ((e[1] & 0x04) >> 2) | ((e[1] & 0x08) << 1);  
+    r[0] = ((S2[index2] & 0x08) >> 3) | ((S2[index2] & 0x04) >> 1) | ((S2[index2] & 0x02) << 1) | ((S2[index2] & 0x01) << 3);
+    r[0] <<= 4;
+    r[0] |= ((S1[index] & 0x08) >> 3) | ((S1[index] & 0x04) >> 1) | ((S1[index] & 0x02) << 1) | ((S1[index] & 0x01) << 3);
+
+
+    index = ((e[1] & 0x10) << 1) | ((e[1] & 0x20) >> 2) | ((e[1] & 0x40) >> 4) | ((e[1] & 0x80) >> 6) | (e[2] & 0x01) | ((e[2] & 0x02) << 3);
+    index2 = ((e[2] & 0x04) << 3) | (e[2] & 0x08) | ((e[2] & 0x10) >> 2) | ((e[2] & 0x20) >> 4) | ((e[2] & 0x40) >> 6) | ((e[2] & 0x80) >> 3);
+
+
+    r[1] = ((S4[index2] & 0x08) >> 3) | ((S4[index2] & 0x04) >> 1) | ((S4[index2] & 0x02) << 1) | ((S4[index2] & 0x01) << 3);
+    r[1] <<= 4;
+    r[1] |= ((S3[index] & 0x08) >> 3) | ((S3[index] & 0x04) >> 1) | ((S3[index] & 0x02) << 1) | ((S3[index] & 0x01) << 3);
+    
+    
+    index = ((e[3] & 0x01) << 5) | ((e[3] & 0x02) << 2) | (e[3] & 0x04)  | ((e[3] & 0x08) >> 2) | ((e[3] & 0x10) >> 4) | ((e[3] & 0x20) >> 1);
+    index2 = ((e[3] & 0x40) >> 1) | ((e[3] & 0x80) >> 4) | ((e[4] & 0x01) << 2) | (e[4] & 0x02) | ((e[4] & 0x04) >> 2) | ((e[4] & 0x08) << 1);  
+    r[2] = ((S6[index2] & 0x08) >> 3) | ((S6[index2] & 0x04) >> 1) | ((S6[index2] & 0x02) << 1) | ((S6[index2] & 0x01) << 3);
+    r[2] <<= 4;
+    r[2] |= ((S5[index] & 0x08) >> 3) | ((S5[index] & 0x04) >> 1) | ((S5[index] & 0x02) << 1) | ((S5[index] & 0x01) << 3);
+
+
+    index = ((e[4] & 0x10) << 1) | ((e[4] & 0x20) >> 2) | ((e[4] & 0x40) >> 4) | ((e[4] & 0x80) >> 6) | (e[5] & 0x01) | ((e[5] & 0x02) << 3);
+    index2 = ((e[5] & 0x04) << 3) | (e[5] & 0x08) | ((e[5] & 0x10) >> 2) | ((e[5] & 0x20) >> 4) | ((e[5] & 0x40) >> 6) | ((e[5] & 0x80) >> 3);
+
+    r[3] = ((S8[index2] & 0x08) >> 3) | ((S8[index2] & 0x04) >> 1) | ((S8[index2] & 0x02) << 1) | ((S8[index2] & 0x01) << 3);
+    r[3] <<= 4;
+    r[3] |= ((S7[index] & 0x08) >> 3) | ((S7[index] & 0x04) >> 1) | ((S7[index] & 0x02) << 1) | ((S7[index] & 0x01) << 3);
+}
+
+
+DES::DES(uint8_t *key):
+Cipher()
+{
+    generateSubKeys(key);
+}
+
+uint32_t DES::getBlockSize() const
+{
+    return 8;
+}
+
+CIPHER_TYPE DES::getType() const
+{
+    return BLOCK_CIPHER;
+};
+
+void DES::generateSubKeys(uint8_t *key)
+{
+
+    for(int i = 0; i < 8; ++i)
+        key[i] = ((key[i] & 0x01) << 7) | ((key[i] & 0x02) << 5) | ((key[i] & 0x04) << 3) | ((key[i] & 0x08) << 1)  | ((key[i] & 0x10) >> 1) | ((key[i] & 0x20) >> 3) | ((key[i] & 0x40) >> 5) | ((key[i] & 0x80) >> 7);
+    
+    uint8_t workingKey[7];
+    pc1(workingKey, key);
+    
+    for(int i = 1; i <= 16; ++i)
+    {
+        leftShift(workingKey);
+        if(i != 9 && i >= 3 && i <=15)
+            leftShift(workingKey);
+        pc2(subKeys[i-1], workingKey);
+    }   
+}
+
+void DES::encrypt(uint8_t *out, uint8_t *in, uint32_t length)
+{
+    uint8_t tmp[8];
+    memcpy(tmp, in, 8);
+    for(int i = 0; i < 8; ++i)
+        tmp[i] = ((tmp[i] & 0x01) << 7) | ((tmp[i] & 0x02) << 5) | ((tmp[i] & 0x04) << 3) | ((tmp[i] & 0x08) << 1)  | ((tmp[i] & 0x10) >> 1) | ((tmp[i] & 0x20) >> 3) | ((tmp[i] & 0x40) >> 5) | ((tmp[i] & 0x80) >> 7);
+
+
+    uint8_t l[4], r[4], tmpR[4], e[6];
+    initialPermutation(tmp);
+    memcpy(l, tmp, 4);
+    memcpy(r, &tmp[4], 4);
+    for(int i = 0; i < 16; ++i)
+    {
+        memcpy(tmpR, r, 4);
+        expand(e, r);
+        for(int j = 0; j < 6; ++j)
+            e[j] ^= subKeys[i][j];
+        substitute(r,e);
+        permutation(r);
+        for(int j = 0; j < 4; ++j)
+            r[j] ^= l[j];
+        
+        memcpy(l, tmpR, 4);
+
+    }
+    memcpy(tmp, r, 4);
+    memcpy(&tmp[4], l, 4);
+    
+    invInitialPermutation(tmp);
+    
+    for(int i = 0; i < 8; ++i)
+    {
+        out[i] = ((tmp[i] & 0x01) << 3) | ((tmp[i] & 0x02) << 1) | ((tmp[i] & 0x04) >> 1) | ((tmp[i] & 0x08) >> 3);
+        out[i] <<= 4;
+        tmp[i] >>= 4;
+        out[i] |= ((tmp[i] & 0x01) << 3) | ((tmp[i] & 0x02) << 1) | ((tmp[i] & 0x04) >> 1) | ((tmp[i] & 0x08) >> 3);
+    }
+}
+
+
+void DES::decrypt(uint8_t *out, uint8_t *in, uint32_t length)
+{
+    uint8_t tmp[8];
+    memcpy(tmp, in, 8);
+    for(int i = 0; i < 8; ++i)
+        tmp[i] = ((tmp[i] & 0x01) << 7) | ((tmp[i] & 0x02) << 5) | ((tmp[i] & 0x04) << 3) | ((tmp[i] & 0x08) << 1)  | ((tmp[i] & 0x10) >> 1) | ((tmp[i] & 0x20) >> 3) | ((tmp[i] & 0x40) >> 5) | ((tmp[i] & 0x80) >> 7);
+    
+    uint8_t l[4], r[4], tmpL[4], e[6];
+    initialPermutation(tmp);
+    memcpy(l, tmp, 4);
+    memcpy(r, &tmp[4], 4);
+    
+    for(int i = 15; i >= 0; --i)
+    {
+        memcpy(tmpL, r, 4);
+        expand(e, r);
+        for(int j = 0; j < 6; ++j)
+            e[j] ^= subKeys[i][j];
+        substitute(r,e);
+        permutation(r);
+        for(int j = 0; j < 4; ++j)
+            r[j] ^= l[j];
+        
+        memcpy(l, tmpL, 4);
+    }
+    
+    memcpy(&tmp[4], l, 4);
+    memcpy(tmp, r, 4); 
+    invInitialPermutation(tmp);
+    
+
+    for(int i = 0; i < 8; ++i)
+    {
+        out[i] = ((tmp[i] & 0x01) << 3) | ((tmp[i] & 0x02) << 1) | ((tmp[i] & 0x04) >> 1) | ((tmp[i] & 0x08) >> 3);
+        out[i] <<= 4;
+        tmp[i] >>= 4;
+        out[i] |= ((tmp[i] & 0x01) << 3) | ((tmp[i] & 0x02) << 1) | ((tmp[i] & 0x04) >> 1) | ((tmp[i] & 0x08) >> 3);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cipher/DES.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,26 @@
+#ifndef DES_H
+#define DES_H
+
+#include "Cipher.h"
+
+
+class DES : public Cipher
+{
+    public :
+    
+        DES(uint8_t* key);
+        
+        virtual void encrypt(uint8_t *out, uint8_t *in, uint32_t length);        
+        virtual void decrypt(uint8_t *out, uint8_t *in, uint32_t length);        
+        virtual uint32_t getBlockSize() const;
+
+        CIPHER_TYPE getType() const;
+        
+    private :
+    
+        void generateSubKeys(uint8_t *key);
+    
+        uint8_t subKeys[16][7];
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cipher/RC4.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,46 @@
+#include "RC4.h"
+
+RC4::RC4(uint8_t *key, uint8_t keyLength):
+Cipher(),
+s(),
+i(0),
+j(0)
+{
+    for(int k = 0; k < 256; ++k)
+        s[k] = k;
+    int l = 0;
+    for(int k = 0; k < 256; ++k)
+    {
+        l = (l + s[k] + key[k % keyLength]) % 256;
+        uint8_t tmp = s[l];
+        s[l] = s[k];
+        s[k] = tmp;
+    } 
+}
+
+uint8_t RC4::encyptByte(uint8_t in)
+{
+    ++i;
+    j += s[i];
+    uint8_t tmp = s[i];
+    s[i] = s[j];
+    s[j] = tmp;
+    uint8_t c = s[(s[i]+s[j])%256];
+    return in^c;
+}
+
+void RC4::encrypt(uint8_t *out, uint8_t *in, uint32_t length)
+{
+    for(uint32_t l = 0; l < length; ++l)
+        out[l] = encyptByte(in[l]);
+}
+
+void RC4::decrypt(uint8_t *out, uint8_t *in, uint32_t length)    
+{
+    encrypt(out, in, length);
+}
+
+uint32_t RC4::getBlockSize() const
+{
+    return 1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cipher/RC4.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,25 @@
+#ifndef RC4_H
+#define RC4_H
+
+#include "Cipher.h"
+
+class RC4 : public Cipher
+{
+    public :
+    
+        RC4(uint8_t *key, uint8_t keyLength);
+        
+        virtual void encrypt(uint8_t *out, uint8_t *in, uint32_t length);        
+        virtual void decrypt(uint8_t *out, uint8_t *in, uint32_t length);        
+        virtual uint32_t getBlockSize() const;
+        
+    private :
+    
+        uint8_t encyptByte(uint8_t in);
+        
+        uint8_t s[256];
+        uint8_t i,j;
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cipher/TDES.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,4 @@
+#ifndef TDES_H
+#define TDES_H
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/HashAlgorithm.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,5 @@
+#include "HashAlgorithm.h"
+
+HashAlgorithm::~HashAlgorithm()
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/HashAlgorithm.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,17 @@
+#ifndef HASH_ALGORITHM_H
+#define HASH_ALGORITHM_H
+
+#include <stdint.h>
+
+class HashAlgorithm
+{
+    public :
+    
+        virtual ~HashAlgorithm();
+        
+        virtual uint8_t outputSize() const = 0;
+        virtual void update(uint8_t *data, uint32_t length) = 0;
+        virtual void finalize(uint8_t *hash) = 0;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/MD2.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,203 @@
+/**
+    Implementation of MD2 as described here:
+    http://tools.ietf.org/html/rfc1319
+*/
+
+#include "MD2.h"
+#include <string.h>
+
+
+static const uint8_t s[] =
+{
+    0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, 
+    0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA, 
+    0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16, 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12, 
+    0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, 0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A, 
+    0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F, 0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21,
+    0x80, 0x7F, 0x5D, 0x9A, 0x5A, 0x90, 0x32, 0x27, 0x35, 0x3E, 0xCC, 0xE7, 0xBF, 0xF7, 0x97, 0x03, 
+    0xFF, 0x19, 0x30, 0xB3, 0x48, 0xA5, 0xB5, 0xD1, 0xD7, 0x5E, 0x92, 0x2A, 0xAC, 0x56, 0xAA, 0xC6, 
+    0x4F, 0xB8, 0x38, 0xD2, 0x96, 0xA4, 0x7D, 0xB6, 0x76, 0xFC, 0x6B, 0xE2, 0x9C, 0x74, 0x04, 0xF1, 
+    0x45, 0x9D, 0x70, 0x59, 0x64, 0x71, 0x87, 0x20, 0x86, 0x5B, 0xCF, 0x65, 0xE6, 0x2D, 0xA8, 0x02, 
+    0x1B, 0x60, 0x25, 0xAD, 0xAE, 0xB0, 0xB9, 0xF6, 0x1C, 0x46, 0x61, 0x69, 0x34, 0x40, 0x7E, 0x0F, 
+    0x55, 0x47, 0xA3, 0x23, 0xDD, 0x51, 0xAF, 0x3A, 0xC3, 0x5C, 0xF9, 0xCE, 0xBA, 0xC5, 0xEA, 0x26, 
+    0x2C, 0x53, 0x0D, 0x6E, 0x85, 0x28, 0x84, 0x09, 0xD3, 0xDF, 0xCD, 0xF4, 0x41, 0x81, 0x4D, 0x52, 
+    0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA, 0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A, 
+    0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D, 0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39, 
+    0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, 0xD0, 0xE4, 0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A, 
+    0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A, 0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14
+};
+
+
+MD2::MD2():
+HashAlgorithm(),
+bufferLength(0),
+l(0)
+{
+    memset(checksum, 0, 16);
+    memset(x, 0, 16);
+}
+
+uint8_t MD2::outputSize() const
+{
+    return 16;
+}
+
+void MD2::update(uint8_t *data, uint32_t length)
+{ 
+    if(bufferLength == 0)
+    {
+        while(length >= 16)
+        {
+            computeBlock(checksum, x, &l, data);
+            length -= 16;
+            data += 16;
+        }
+        bufferLength = length;
+        memcpy(buffer, data, length);
+    }
+    else if(length < 16-bufferLength)
+    {
+        memcpy(&buffer[bufferLength], data, length);
+        bufferLength += length;
+    }
+    else
+    {
+        int offset = 16-bufferLength;
+        memcpy(&buffer[bufferLength], data, offset);
+        computeBlock(checksum, x, &l, buffer);
+        data += offset;
+        length -= offset;
+        while(length >= 16)
+        {
+            computeBlock(checksum, x, &l, data);
+            data += 16;
+            length -= 16;
+        }
+        bufferLength = length;
+        memcpy(buffer, &data, length);
+    }
+    
+}
+
+void MD2::finalize(uint8_t *hash)
+{
+    // compute what's left data the buffer
+    int padding = 16 - bufferLength;
+    memset(&buffer[bufferLength], padding, padding);
+    computeBlock(checksum, x, &l, buffer);
+    computeBlock(checksum, x, &l, checksum);
+    memcpy(hash, x, 16);
+
+    uint32_t *x2 = (uint32_t*)x;
+    uint32_t *checksum2 = (uint32_t*)checksum;
+
+    // reset state
+    bufferLength = 0;
+    l = 0;
+    checksum2[0] = x2[0] = 0;
+    checksum2[1] = x2[1] = 0;
+    checksum2[2] = x2[2] = 0;
+    checksum2[3] = x2[3] = 0;
+}
+
+void MD2::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
+{
+    uint8_t x[48];
+    uint8_t checksum[16];
+    uint8_t buffer[16];
+    memset(x, 0, 16);
+    memset(checksum, 0, 16);
+    uint8_t l = 0;
+    while(length >= 16)
+    {
+        computeBlock(checksum, x, &l, data);
+        length -= 16;
+        data += 16;
+    }
+
+    memcpy(buffer, data, length);
+    uint8_t padding = 16-length;
+    memset(&buffer[length], padding, padding);
+    computeBlock(checksum, x, &l, buffer);
+    computeBlock(checksum,x, &l, checksum);
+    memcpy(hash, x, 16);
+}
+
+void MD2::computeBlock(uint8_t *checksum2, uint8_t *x2, uint8_t *l2, uint8_t *buffer2)
+{
+    if(checksum2 != buffer2)
+    {
+        #pragma unroll_completely   
+        for(int j = 0; j < 16; ++j)
+        {
+            uint8_t c = buffer2[j];
+            *l2 = (checksum2[j] ^= s[c^(*l2)]);
+        }
+    }
+    
+    uint32_t *x3 = (uint32_t*)x2;
+    uint32_t *buffer3 = (uint32_t*)buffer2;
+    
+    x3[4] = buffer3[0];
+    x3[5] = buffer3[1];
+    x3[6] = buffer3[2];
+    x3[7] = buffer3[3];
+    for(int j = 0; j < 4; ++j)
+        x3[8+j] = x3[4+j] ^ x3[j];
+    
+    uint8_t t = 0;
+    
+    for(int j = 0; j < 18; ++j)
+    {
+        t = (x2[0] ^= s[t]);
+        t = (x2[1] ^= s[t]);
+        t = (x2[2] ^= s[t]);
+        t = (x2[3] ^= s[t]);
+        t = (x2[4] ^= s[t]);
+        t = (x2[5] ^= s[t]);
+        t = (x2[6] ^= s[t]);
+        t = (x2[7] ^= s[t]);
+        t = (x2[8] ^= s[t]);
+        t = (x2[9] ^= s[t]);
+        t = (x2[10] ^= s[t]);
+        t = (x2[11] ^= s[t]);
+        t = (x2[12] ^= s[t]);
+        t = (x2[13] ^= s[t]);
+        t = (x2[14] ^= s[t]);
+        t = (x2[15] ^= s[t]);
+        t = (x2[16] ^= s[t]);
+        t = (x2[17] ^= s[t]);
+        t = (x2[18] ^= s[t]);
+        t = (x2[19] ^= s[t]);
+        t = (x2[20] ^= s[t]);
+        t = (x2[21] ^= s[t]);
+        t = (x2[22] ^= s[t]);
+        t = (x2[23] ^= s[t]);            
+        t = (x2[24] ^= s[t]);
+        t = (x2[25] ^= s[t]);
+        t = (x2[26] ^= s[t]);
+        t = (x2[27] ^= s[t]);
+        t = (x2[28] ^= s[t]);
+        t = (x2[29] ^= s[t]);
+        t = (x2[30] ^= s[t]);
+        t = (x2[31] ^= s[t]);
+        t = (x2[32] ^= s[t]);
+        t = (x2[33] ^= s[t]);
+        t = (x2[34] ^= s[t]);
+        t = (x2[35] ^= s[t]);
+        t = (x2[36] ^= s[t]);
+        t = (x2[37] ^= s[t]);
+        t = (x2[38] ^= s[t]);
+        t = (x2[39] ^= s[t]);
+        t = (x2[40] ^= s[t]);
+        t = (x2[41] ^= s[t]);
+        t = (x2[42] ^= s[t]);
+        t = (x2[43] ^= s[t]);
+        t = (x2[44] ^= s[t]);
+        t = (x2[45] ^= s[t]);
+        t = (x2[46] ^= s[t]);
+        t = (x2[47] ^= s[t]);            
+
+        t += j;
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/MD2.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,30 @@
+#ifndef MD2_H
+#define MD2_H
+
+#include "HashAlgorithm.h"
+
+class MD2 : public HashAlgorithm
+{
+    public :
+    
+        MD2();
+        
+        virtual uint8_t outputSize() const;
+        virtual void update(uint8_t *data, uint32_t length);
+        virtual void finalize(uint8_t *hash);
+        
+        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
+        
+    private :
+          
+        static void computeBlock(uint8_t *checksum, uint8_t *x, uint8_t *l2, uint8_t *buffer2);
+    
+        uint8_t bufferLength;
+        uint8_t l;
+        uint8_t buffer[16];
+        uint8_t checksum[16];
+        uint8_t x[48];
+};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/MD5.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,198 @@
+/**
+    Implementation of MD5 as described here:
+    http://tools.ietf.org/html/rfc1321
+*/
+
+#include "MD5.h"
+#include <string.h>
+
+static const uint32_t A = 0x67452301;
+static const uint32_t B = 0xefcdab89;
+static const uint32_t C = 0x98badcfe;
+static const uint32_t D = 0x10325476;
+
+
+#define F(X,Y,Z) (((X) & (Y)) | ((~(X)) & (Z)))
+#define G(X,Y,Z) (((X) & (Z)) | ((Y) & (~(Z))))
+#define H(X,Y,Z) ((X) ^ (Y) ^ (Z))
+#define I(X,Y,Z) ((Y) ^ ((X) | (~(Z))))
+
+#define ROTL(W,N) (((W) << N) | ((W) >> (32-N)))
+
+#define ROUND1(a,b,c,d,x,s,t) \
+    a = ROTL(a + F(b,c,d) + x + t,s) + b; 
+
+#define ROUND2(a,b,c,d,x,s,t) \
+    a = ROTL(a + G(b,c,d) + x + t,s) + b; 
+
+#define ROUND3(a,b,c,d,x,s,t) \
+    a = ROTL(a + H(b,c,d) + x + t,s) + b; 
+
+#define ROUND4(a,b,c,d,x,s,t) \
+    a = ROTL(a + I(b,c,d) + x + t,s) + b; 
+
+
+    
+MD5::MD5():
+HashAlgorithm(),
+a(A),
+b(B),
+c(C),
+d(D),
+totalBufferLength(0),
+buffer(),
+bufferLength(0)
+{
+}
+
+uint8_t MD5::outputSize() const
+{
+    return 16;
+}
+
+void MD5::update(uint8_t *data, uint32_t length)
+{
+    if(length < 64-bufferLength)
+    {
+        memcpy(&buffer[bufferLength], data, length);
+        bufferLength += length;
+        totalBufferLength += length;
+        return;
+    }
+    int offset = 64-bufferLength;
+    memcpy(&buffer[bufferLength], data, offset);
+    computeRounds(&a, &b, &c, &d, buffer);
+    while(length-offset > 64)
+    {
+        memcpy(buffer, &data[offset], 64);
+        computeRounds(&a, &b, &c, &d, buffer);
+        offset += 64;
+    }
+    if(offset > length)
+        offset -= 64;
+    bufferLength = length - offset;
+    memcpy(buffer, &data[offset], bufferLength);
+    totalBufferLength += length;
+}
+
+void MD5::finalize(uint8_t *hash)
+{
+    uint32_t *hash2 = (uint32_t*)hash;
+    uint16_t padding;
+    if(totalBufferLength % 64 < 56)
+        padding = 56 - (totalBufferLength % 64);
+    else
+        padding = 56 + (64 - (totalBufferLength % 64));
+    buffer[bufferLength++] = 0x80;
+    padding--;
+    if(padding+bufferLength == 56)
+        memset(&buffer[bufferLength], 0, padding);
+    else
+    {
+        memset(&buffer[bufferLength], 0, 64-bufferLength);
+        computeRounds(&a, &b, &c, &d, buffer);
+        memset(buffer, 0, 56);
+    }
+    uint64_t lengthBit = totalBufferLength << 3;
+    uint32_t lengthBitLow = lengthBit;
+    uint32_t lengthBitHigh = lengthBit >> 32;
+    memcpy(&buffer[56], &lengthBitLow, 4);
+    memcpy(&buffer[60], &lengthBitHigh, 4);
+    computeRounds(&a, &b, &c, &d, buffer);
+
+    hash2[0] = a;
+    hash2[1] = b;
+    hash2[2] = c;
+    hash2[3] = d;
+    // reset state
+    a = A;
+    b = B;
+    c = C;
+    d = D;
+    totalBufferLength = 0;
+    bufferLength = 0;
+}
+
+
+void MD5::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
+{
+    uint32_t *hash2 = (uint32_t*)hash;
+    uint64_t lengthBit = length << 3;
+    uint16_t padding;
+    if(length % 64 < 56)
+        padding = 56 - (length % 64);
+    else
+        padding = 56 + (64 - (length % 64));
+        
+    uint32_t a = A, b = B, c = C, d = D;
+    while(length >= 64)
+    {
+        computeRounds(&a, &b, &c, &d, data);
+        data += 64;
+        length -= 64;
+    }
+    uint8_t buffer[64];
+    memcpy(buffer, data, length);
+    buffer[length++] = 0x80;
+    padding--;
+    if(padding+length == 56)
+        memset(&buffer[length], 0, padding);
+    else
+    {
+        memset(&buffer[length], 0, 64-length);
+        computeRounds(&a, &b, &c, &d, data);
+        memset(buffer, 0, 56);
+    }
+
+    uint32_t lengthBitLow = lengthBit;
+    uint32_t lengthBitHigh = lengthBit >> 32;
+    memcpy(&buffer[56], &lengthBitLow, 4);
+    memcpy(&buffer[60], &lengthBitHigh, 4);
+    
+    computeRounds(&a, &b, &c, &d, buffer);
+    
+    hash2[0] = a;
+    hash2[1] = b;
+    hash2[2] = c;
+    hash2[3] = d;
+}
+
+void MD5::computeRounds(uint32_t *a2, uint32_t *b2, uint32_t *c2, uint32_t *d2, uint8_t *buffer)
+{
+    uint32_t a = *a2, b = *b2, c = *c2, d = *d2;
+    uint32_t tmpA = a, tmpB = b, tmpC = c, tmpD = d;
+
+    uint32_t *x = (uint32_t*)buffer;
+       
+    // Round 1
+    ROUND1(a,b,c,d,x[0],7,0xd76aa478);     ROUND1(d,a,b,c,x[1],12,0xe8c7b756);    ROUND1(c,d,a,b,x[2],17,0x242070db);    ROUND1(b,c,d,a,x[3],22,0xc1bdceee);
+    ROUND1(a,b,c,d,x[4],7,0xf57c0faf);     ROUND1(d,a,b,c,x[5],12,0x4787c62a);    ROUND1(c,d,a,b,x[6],17,0xa8304613);    ROUND1(b,c,d,a,x[7],22,0xfd469501);
+    ROUND1(a,b,c,d,x[8],7,0x698098d8);     ROUND1(d,a,b,c,x[9],12,0x8b44f7af);    ROUND1(c,d,a,b,x[10],17,0xffff5bb1);   ROUND1(b,c,d,a,x[11],22,0x895cd7be);
+    ROUND1(a,b,c,d,x[12],7,0x6b901122);    ROUND1(d,a,b,c,x[13],12,0xfd987193);   ROUND1(c,d,a,b,x[14],17,0xa679438e);   ROUND1(b,c,d,a,x[15],22,0x49b40821);
+
+
+    // Round 2      
+    ROUND2(a,b,c,d,x[1],5,0xf61e2562);     ROUND2(d,a,b,c,x[6],9,0xc040b340);     ROUND2(c,d,a,b,x[11],14,0x265e5a51);   ROUND2(b,c,d,a,x[0],20,0xe9b6c7aa);
+    ROUND2(a,b,c,d,x[5],5,0xd62f105d);     ROUND2(d,a,b,c,x[10],9,0x02441453);    ROUND2(c,d,a,b,x[15],14,0xd8a1e681);   ROUND2(b,c,d,a,x[4],20,0xe7d3fbc8);
+    ROUND2(a,b,c,d,x[9],5,0x21e1cde6);     ROUND2(d,a,b,c,x[14],9,0xc33707d6);    ROUND2(c,d,a,b,x[3],14,0xf4d50d87);    ROUND2(b,c,d,a,x[8],20,0x455a14ed);
+    ROUND2(a,b,c,d,x[13],5,0xa9e3e905);    ROUND2(d,a,b,c,x[2],9,0xfcefa3f8);     ROUND2(c,d,a,b,x[7],14,0x676f02d9);    ROUND2(b,c,d,a,x[12],20,0x8d2a4c8a);
+    
+
+    // Round 3      
+    ROUND3(a,b,c,d,x[5],4,0xfffa3942);     ROUND3(d,a,b,c,x[8],11,0x8771f681);    ROUND3(c,d,a,b,x[11],16,0x6d9d6122);   ROUND3(b,c,d,a,x[14],23,0xfde5380c);
+    ROUND3(a,b,c,d,x[1],4,0xa4beea44);     ROUND3(d,a,b,c,x[4],11,0x4bdecfa9);    ROUND3(c,d,a,b,x[7],16,0xf6bb4b60);    ROUND3(b,c,d,a,x[10],23,0xbebfbc70);
+    ROUND3(a,b,c,d,x[13],4,0x289b7ec6);    ROUND3(d,a,b,c,x[0],11,0xeaa127fa);    ROUND3(c,d,a,b,x[3],16,0xd4ef3085);    ROUND3(b,c,d,a,x[6],23,0x04881d05);
+    ROUND3(a,b,c,d,x[9],4,0xd9d4d039);     ROUND3(d,a,b,c,x[12],11,0xe6db99e5);   ROUND3(c,d,a,b,x[15],16,0x1fa27cf8);   ROUND3(b,c,d,a,x[2],23,0xc4ac5665);
+ 
+ 
+    // Round 4
+    ROUND4(a,b,c,d,x[0],6,0xf4292244);     ROUND4(d,a,b,c,x[7],10,0x432aff97);    ROUND4(c,d,a,b,x[14],15,0xab9423a7);   ROUND4(b,c,d,a,x[5],21,0xfc93a039);
+    ROUND4(a,b,c,d,x[12],6,0x655b59c3);    ROUND4(d,a,b,c,x[3],10,0x8f0ccc92);    ROUND4(c,d,a,b,x[10],15,0xffeff47d);   ROUND4(b,c,d,a,x[1],21,0x85845dd1);
+    ROUND4(a,b,c,d,x[8],6,0x6fa87e4f);     ROUND4(d,a,b,c,x[15],10,0xfe2ce6e0);   ROUND4(c,d,a,b,x[6],15,0xa3014314);    ROUND4(b,c,d,a,x[13],21,0x4e0811a1);
+    ROUND4(a,b,c,d,x[4],6,0xf7537e82);     ROUND4(d,a,b,c,x[11],10,0xbd3af235);   ROUND4(c,d,a,b,x[2],15,0x2ad7d2bb);    ROUND4(b,c,d,a,x[9],21,0xeb86d391);
+    
+    *a2 = a + tmpA;
+    *b2 = b + tmpB;
+    *c2 = c + tmpC;
+    *d2 = d + tmpD;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/MD5.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,29 @@
+#ifndef MD5_H
+#define MD5_H
+
+#include "HashAlgorithm.h"
+
+
+class MD5 : public HashAlgorithm
+{
+    public :
+    
+        MD5();
+        
+        virtual uint8_t outputSize() const;
+        virtual void update(uint8_t *data, uint32_t length);
+        virtual void finalize(uint8_t *hash);
+        
+        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
+        
+    private :
+    
+        static void computeRounds(uint32_t *a2, uint32_t *b2, uint32_t *c2, uint32_t *d2, uint8_t *buffer);
+        
+        uint32_t a,b,c,d;
+        uint32_t totalBufferLength;
+        uint8_t buffer[64];
+        uint8_t bufferLength;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA1.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,221 @@
+/**
+    Implementation of SHA-1 as described here:
+    http://tools.ietf.org/html/rfc1319
+*/
+
+#include "SHA1.h"
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define F0(B,C,D) ((B & C) | ((~B) & D))
+#define F1(B,C,D) (B ^ C ^ D)
+#define F2(B,C,D) ((B & C) | (B & D) | (C & D))
+#define ROTL(W,N) (((W) << N) | ((W) >> (32-N)))
+                        
+static const uint32_t K0 = 0x5A827999;
+static const uint32_t K1 = 0x6ED9EBA1;
+static const uint32_t K2 = 0x8F1BBCDC;
+static const uint32_t K3 = 0xCA62C1D6;
+
+
+static const uint32_t H0 = 0x67452301;
+static const uint32_t H1 = 0xEFCDAB89;
+static const uint32_t H2 = 0x98BADCFE;
+static const uint32_t H3 = 0x10325476;
+static const uint32_t H4 = 0xC3D2E1F0;
+
+static const uint32_t MASK = 0xF;
+
+#define W(s) ( w[s] = ROTL(w[((s) + 13) & MASK] ^ w[((s) + 8) & MASK] ^ w[((s) + 2) & MASK] ^ w[s],1))
+
+#define R0(A,B,C,D,E,T) E += ROTL(A, 5) + F0(B, C, D) + w[T] + K0; \
+                        B = ROTL(B,30);
+#define R1(A,B,C,D,E,T) E += ROTL(A, 5) + F0(B, C, D) + W(T & MASK) + K0; \
+                        B = ROTL(B,30); 
+#define R2(A,B,C,D,E,T) E += ROTL(A, 5) + F1(B, C, D) + W(T & MASK) + K1; \
+                        B = ROTL(B,30); 
+#define R3(A,B,C,D,E,T) E += ROTL(A, 5) + F2(B, C, D) + W(T & MASK) + K2; \
+                        B = ROTL(B,30); 
+#define R4(A,B,C,D,E,T) E += ROTL(A, 5) + F1(B, C, D) + W(T & MASK) + K3; \
+                        B = ROTL(B,30); 
+
+                        
+SHA1::SHA1():
+HashAlgorithm(),
+h0(H0),
+h1(H1),
+h2(H2),
+h3(H3),
+h4(H4),
+totalBufferLength(0),
+buffer(),
+bufferLength(0)
+{
+}
+
+uint8_t SHA1::outputSize() const
+{
+    return 20;
+}
+
+void SHA1::update(uint8_t *data, uint32_t length)
+{
+    if(length < 64-bufferLength)
+    {
+        memcpy(&buffer[bufferLength], data, length);
+        bufferLength += length;
+        totalBufferLength += length;
+        return;
+    }
+    int offset = 64-bufferLength;
+    memcpy(&buffer[bufferLength], data, offset);
+    computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
+    while(length-offset > 64)
+    {
+        memcpy(buffer, &data[offset], 64);
+        computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
+        offset += 64;
+    }
+    if(offset > length)
+        offset -= 64;
+    bufferLength = length - offset;
+    memcpy(buffer, &data[offset], bufferLength);
+    totalBufferLength += length;
+}
+
+void SHA1::finalize(uint8_t *hash)
+{
+    uint32_t *hash2 = (uint32_t*)hash;
+    uint16_t padding;
+    if(totalBufferLength % 64 < 56)
+        padding = 56 - (totalBufferLength % 64);
+    else
+        padding = 56 + (64 - (totalBufferLength % 64));
+        
+    buffer[bufferLength++] = 0x80;
+    padding--;
+    if(padding+bufferLength == 56)
+        memset(&buffer[bufferLength], 0, padding);
+    else
+    {
+        memset(&buffer[bufferLength], 0, 64-bufferLength);
+        computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
+        memset(buffer, 0, 56);
+    }
+    
+    uint64_t lengthBit = totalBufferLength << 3;
+    uint32_t lengthBitLow = lengthBit;
+    uint32_t lengthBitHigh = lengthBit >> 32;
+    lengthBitLow = __rev(lengthBitLow);
+    lengthBitHigh = __rev(lengthBitHigh);
+    memcpy(&buffer[56], &lengthBitHigh, 4);
+    memcpy(&buffer[60], &lengthBitLow, 4);
+    computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
+    
+    hash2[0] = __rev(h0);
+    hash2[1] = __rev(h1);
+    hash2[2] = __rev(h2);
+    hash2[3] = __rev(h3);
+    hash2[4] = __rev(h4);
+    
+    // reset state
+    h0 = H0;
+    h1 = H1;
+    h2 = H2;
+    h3 = H3;
+    h4 = H4;
+    totalBufferLength = 0;
+    bufferLength = 0;
+}
+
+
+void SHA1::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
+{
+    uint32_t *hash2 = (uint32_t*)hash;
+    uint64_t lengthBit = length << 3;
+    uint32_t padding;
+    if(length % 64 < 56)
+        padding = 56 - (length % 64);
+    else
+        padding = 56 + (64 - (length % 64));
+        
+    uint32_t h0 = H0, h1 = H1, h2 = H2, h3 = H3, h4 = H4;
+    while(length >= 64)
+    {
+        computeBlock(&h0,&h1,&h2,&h3,&h4, data);
+        length -= 64;
+        data += 64;
+    }
+   
+    uint8_t buffer[64];
+    memcpy(buffer, data, length);
+    buffer[length++] = 0x80;
+    padding--;
+    if(padding+length+8 == 64)
+        memset(&buffer[length], 0, padding);
+    else
+    {
+        memset(&buffer[length], 0, 64-length);
+        computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
+        memset(buffer, 0, 56);
+    }
+
+    uint32_t lengthBitLow = lengthBit;
+    uint32_t lengthBitHigh = lengthBit >> 32;
+    lengthBitLow = __rev(lengthBitLow);
+    lengthBitHigh = __rev(lengthBitHigh);
+    memcpy(&buffer[60], &lengthBitLow, 4);
+    memcpy(&buffer[56], &lengthBitHigh, 4);
+    
+    computeBlock(&h0,&h1,&h2,&h3,&h4, buffer);
+
+    hash2[0] = __rev(h0);
+    hash2[1] = __rev(h1);
+    hash2[2] = __rev(h2);
+    hash2[3] = __rev(h3);
+    hash2[4] = __rev(h4);
+}
+
+void SHA1::computeBlock(uint32_t *h02, uint32_t *h12, uint32_t *h22, uint32_t *h32, uint32_t *h42, uint8_t *buffer)
+{
+    uint32_t *buffer2 = (uint32_t*)buffer;
+    uint32_t w[16];
+    for(int t = 0; t < 16; ++t)
+        w[t] = __rev(buffer2[t]);
+    
+    uint32_t a = *h02, b = *h12, c = *h22, d = *h32, e = *h42;
+    
+    R0(a,b,c,d,e, 0) R0(e,a,b,c,d, 1) R0(d,e,a,b,c, 2) R0(c,d,e,a,b, 3)
+    R0(b,c,d,e,a, 4) R0(a,b,c,d,e, 5) R0(e,a,b,c,d, 6) R0(d,e,a,b,c, 7)
+    R0(c,d,e,a,b, 8) R0(b,c,d,e,a, 9) R0(a,b,c,d,e,10) R0(e,a,b,c,d,11)
+    R0(d,e,a,b,c,12) R0(c,d,e,a,b,13) R0(b,c,d,e,a,14) R0(a,b,c,d,e,15)
+    R1(e,a,b,c,d,16) R1(d,e,a,b,c,17) R1(c,d,e,a,b,18) R1(b,c,d,e,a,19)    
+    
+    
+    R2(a,b,c,d,e,20) R2(e,a,b,c,d,21) R2(d,e,a,b,c,22) R2(c,d,e,a,b,23)
+    R2(b,c,d,e,a,24) R2(a,b,c,d,e,25) R2(e,a,b,c,d,26) R2(d,e,a,b,c,27)
+    R2(c,d,e,a,b,28) R2(b,c,d,e,a,29) R2(a,b,c,d,e,30) R2(e,a,b,c,d,31)
+    R2(d,e,a,b,c,32) R2(c,d,e,a,b,33) R2(b,c,d,e,a,34) R2(a,b,c,d,e,35)
+    R2(e,a,b,c,d,36) R2(d,e,a,b,c,37) R2(c,d,e,a,b,38) R2(b,c,d,e,a,39)    
+    
+    R3(a,b,c,d,e,40) R3(e,a,b,c,d,41) R3(d,e,a,b,c,42) R3(c,d,e,a,b,43)
+    R3(b,c,d,e,a,44) R3(a,b,c,d,e,45) R3(e,a,b,c,d,46) R3(d,e,a,b,c,47)
+    R3(c,d,e,a,b,48) R3(b,c,d,e,a,49) R3(a,b,c,d,e,50) R3(e,a,b,c,d,51)
+    R3(d,e,a,b,c,52) R3(c,d,e,a,b,53) R3(b,c,d,e,a,54) R3(a,b,c,d,e,55)
+    R3(e,a,b,c,d,56) R3(d,e,a,b,c,57) R3(c,d,e,a,b,58) R3(b,c,d,e,a,59)    
+    
+    
+    R4(a,b,c,d,e,60) R4(e,a,b,c,d,61) R4(d,e,a,b,c,62) R4(c,d,e,a,b,63)
+    R4(b,c,d,e,a,64) R4(a,b,c,d,e,65) R4(e,a,b,c,d,66) R4(d,e,a,b,c,67)
+    R4(c,d,e,a,b,68) R4(b,c,d,e,a,69) R4(a,b,c,d,e,70) R4(e,a,b,c,d,71)
+    R4(d,e,a,b,c,72) R4(c,d,e,a,b,73) R4(b,c,d,e,a,74) R4(a,b,c,d,e,75)
+    R4(e,a,b,c,d,76) R4(d,e,a,b,c,77) R4(c,d,e,a,b,78) R4(b,c,d,e,a,79)    
+        
+    *h02 += a;
+    *h12 += b;
+    *h22 += c;
+    *h32 += d;
+    *h42 += e;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA1.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,28 @@
+#ifndef SHA1_H
+#define SHA1_H
+
+#include "HashAlgorithm.h"
+
+
+class SHA1 : public HashAlgorithm
+{
+    public :
+    
+        SHA1();
+
+        virtual uint8_t outputSize() const;        
+        virtual void update(uint8_t *data, uint32_t length);
+        virtual void finalize(uint8_t *hash);
+        
+        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
+        
+    private :
+        static void computeBlock(uint32_t *h02, uint32_t *h12, uint32_t *h22, uint32_t *h32, uint32_t *h42, uint8_t *buffer);
+    
+        uint32_t h0, h1, h2, h3, h4;
+        uint32_t totalBufferLength;
+        uint8_t buffer[64];
+        uint8_t bufferLength;       
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA2.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,9 @@
+#ifndef SHA2_H
+#define SHA2_H
+
+#include "SHA224.h"
+#include "SHA256.h"
+#include "SHA384.h"
+#include "SHA512.h"
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA224.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,28 @@
+#include "SHA224.h"
+
+
+SHA224::SHA224():
+HashAlgorithm(),
+algo(SHA_224)
+{
+}
+
+uint8_t SHA224::outputSize() const
+{
+    return 28;
+}
+
+void SHA224::update(uint8_t *data, uint32_t length)
+{
+    algo.update(data, length);
+}
+
+void SHA224::finalize(uint8_t *hash)
+{
+    algo.finalize(hash);
+}
+
+void SHA224::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
+{
+    SHA2_32::computeHash(SHA_224, hash, data, length);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA224.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,24 @@
+#ifndef SHA2_224_H
+#define SHA2_224_H
+
+#include "HashAlgorithm.h"
+#include "SHA2_32.h"
+
+class SHA224 : public HashAlgorithm
+{
+    public :
+
+        SHA224();
+
+        virtual uint8_t outputSize() const;
+        virtual void update(uint8_t *data, uint32_t length);
+        virtual void finalize(uint8_t *hash);
+
+        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
+
+    private :
+    
+        SHA2_32 algo;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA256.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,28 @@
+#include "SHA256.h"
+
+
+SHA256::SHA256():
+HashAlgorithm(),
+algo(SHA_256)
+{
+}
+
+uint8_t SHA256::outputSize() const
+{
+    return 32;
+}
+
+void SHA256::update(uint8_t *data, uint32_t length)
+{
+    algo.update(data, length);
+}
+
+void SHA256::finalize(uint8_t *hash)
+{
+    algo.finalize(hash);
+}
+
+void SHA256::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
+{
+    SHA2_32::computeHash(SHA_256, hash, data, length);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA256.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,25 @@
+#ifndef SHA2_256_H
+#define SHA2_256_H
+
+#include "HashAlgorithm.h"
+#include "SHA2_32.h"
+
+
+class SHA256 : public HashAlgorithm
+{
+    public :
+
+        SHA256();
+        
+        virtual uint8_t outputSize() const;
+        virtual void update(uint8_t *data, uint32_t length);
+        virtual void finalize(uint8_t *hash);
+
+        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
+
+    private :
+    
+        SHA2_32 algo;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA2_32.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,314 @@
+#include "SHA2_32.h"
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static const uint8_t MASK = 0x0F;
+#define W(t) (w[(t)] = SSIG1(w[((t)+14)&MASK]) + w[((t)+9)&MASK] + SSIG0(w[((t)+1)&MASK]) + w[t])
+
+#define ROTL(W,N) (((W) << (N)) | ((W) >> (32-(N))))
+#define ROTR(W,N) (((W) >> (N)) | ((W) << (32-(N))))
+#define CH(X,Y,Z) (((X) & (Y)) ^ ((~(X)) & (Z)))
+#define MAJ(X,Y,Z) (((X) & (Y)) ^ ((X) & (Z)) ^ ((Y) & (Z)))
+#define BSIG0(X) (ROTR(X,2) ^ ROTR(X,13) ^ ROTR(X,22))
+#define BSIG1(X) (ROTR(X,6) ^ ROTR(X,11) ^ ROTR(X,25))
+#define SSIG0(X) (ROTR((X),7) ^ ROTR((X),18) ^ ((X) >> 3))
+#define SSIG1(X) (ROTR((X),17) ^ ROTR((X),19) ^ ((X) >> 10))
+#define R(A,B,C,D,E,F,G,H,T,K)  T1 = H + BSIG1(E) + CH(E,F,G) + K + (w[T] = __rev(buffer2[T])); \
+                              T2 = BSIG0(A) + MAJ(A,B,C); \
+                              D += T1; \
+                              H = T1 + T2;
+#define R2(A,B,C,D,E,F,G,H,T,K)  T1 = H + BSIG1(E) + CH(E,F,G) + K + W(T&MASK); \
+                              T2 = BSIG0(A) + MAJ(A,B,C); \
+                              D += T1; \
+                              H = T1 + T2;
+        
+static const uint32_t H[] =
+{
+    // SHA-224
+    0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
+    0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,
+    
+    // SHA-256      
+    0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
+    0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
+};
+
+SHA2_32::SHA2_32(SHA_32_TYPE t):
+type(t),
+totalBufferLength(0),
+bufferLength(0)
+{
+    switch(type)
+    {
+        case SHA_224:
+            h0 = H[0];
+            h1 = H[1];
+            h2 = H[2];
+            h3 = H[3];
+            h4 = H[4];
+            h5 = H[5];
+            h6 = H[6];
+            h7 = H[7];
+        break;
+        
+        case SHA_256:
+            h0 = H[8];
+            h1 = H[9];
+            h2 = H[10];
+            h3 = H[11];
+            h4 = H[12];
+            h5 = H[13];
+            h6 = H[14];
+            h7 = H[15];     
+        break;
+    }
+}
+
+void SHA2_32::update(uint8_t *data, uint32_t length)
+{
+    if(length < 64-bufferLength)
+    {
+        memcpy(&buffer[bufferLength], data, length);
+        bufferLength += length;
+        totalBufferLength += length;
+        return;
+    }
+    int offset = 64-bufferLength;
+    memcpy(&buffer[bufferLength], data, offset);
+    computeBlock(&h0,&h1,&h2,&h3,&h4,&h5,&h6,&h7,buffer);
+    while(length-offset > 64)
+    {
+        memcpy(buffer, &data[offset], 64);
+        computeBlock(&h0,&h1,&h2,&h3,&h4,&h5,&h6,&h7,buffer);
+        offset += 64;
+    }
+    if(offset > length)
+        offset -= 64;
+    bufferLength = length - offset;
+    memcpy(buffer, &data[offset], bufferLength);
+    totalBufferLength += length;
+}
+
+void SHA2_32::finalize(uint8_t *hash)
+{
+    uint32_t *hash2 = (uint32_t*)hash;
+    uint16_t padding;
+    if(totalBufferLength % 64 < 56)
+        padding = 56 - (totalBufferLength % 64);
+    else
+        padding = 56 + (64 - (totalBufferLength % 64));
+
+    buffer[bufferLength++] = 0x80;
+    padding--;
+    if(padding+bufferLength == 56)
+        memset(&buffer[bufferLength], 0, padding);
+    else
+    {
+        memset(&buffer[bufferLength], 0, 64-bufferLength);
+        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
+        memset(buffer, 0, 56);
+    }
+    
+    uint64_t lengthBit = totalBufferLength << 3;
+    uint32_t lengthBitLow = lengthBit;
+    uint32_t lengthBitHigh = lengthBit >> 32;
+    lengthBitLow = __rev(lengthBitLow);
+    lengthBitHigh = __rev(lengthBitHigh);
+    memcpy(&buffer[60], &lengthBitLow, 4);    
+    memcpy(&buffer[56], &lengthBitHigh, 4);    
+    computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
+
+    hash2[0] = __rev(h0);
+    hash2[1] = __rev(h1);
+    hash2[2] = __rev(h2);
+    hash2[3] = __rev(h3);
+    hash2[4] = __rev(h4);
+    hash2[5] = __rev(h5);
+    hash2[6] = __rev(h6);
+
+    
+    if(type == SHA_256)
+        hash2[7] = __rev(h7);
+    
+    // reset state
+    switch(type)
+    {
+        case SHA_224:
+            h0 = H[0];
+            h1 = H[1];
+            h2 = H[2];
+            h3 = H[3];
+            h4 = H[4];
+            h5 = H[5];
+            h6 = H[6];
+            h7 = H[7];
+        break;
+        
+        case SHA_256:
+            h0 = H[8];
+            h1 = H[9];
+            h2 = H[10];
+            h3 = H[11];
+            h4 = H[12];
+            h5 = H[13];
+            h6 = H[14];
+            h7 = H[15];     
+        break;
+    }
+    totalBufferLength = 0;
+    bufferLength = 0;
+}
+
+void SHA2_32::computeHash(SHA_32_TYPE type, uint8_t *hash, uint8_t *data, uint32_t length)
+{
+    uint32_t *hash2 = (uint32_t*)hash;
+    uint32_t h0 = H[type*8], h1 = H[type*8+1], h2 = H[type*8+2], h3 = H[type*8+3];
+    uint32_t h4 = H[type*8+4], h5 = H[type*8+5], h6 = H[type*8+6], h7 = H[type*8+7];
+    uint64_t lengthBit = length << 3;
+    uint16_t padding;
+    if(length % 64 < 56)
+        padding = 56 - (length % 64);
+    else
+        padding = 56 + (64 - (length % 64));
+        
+    while(length >= 64)
+    {
+        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, data);
+        length -= 64;
+        data += 64;
+    }
+    uint8_t buffer[64];
+    memcpy(buffer, data,length); 
+    buffer[length++] = 0x80;
+    padding--;
+    if(padding+length == 56)
+        memset(&buffer[length], 0, padding);
+    else
+    {
+        memset(&buffer[length], 0, 64-length);
+        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
+        memset(buffer, 0, 56);
+    }
+    
+    uint32_t lengthBitLow = lengthBit;
+    uint32_t lengthBitHigh = lengthBit >> 32;
+    lengthBitLow = __rev(lengthBitLow);
+    memcpy(&buffer[60], &lengthBitLow, 4);
+    lengthBitHigh = __rev(lengthBitHigh);
+    memcpy(&buffer[56], &lengthBitHigh, 4);    
+    computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
+
+    hash2[0] = __rev(h0);
+    hash2[1] = __rev(h1);
+    hash2[2] = __rev(h2);
+    hash2[3] = __rev(h3);
+    hash2[4] = __rev(h4);
+    hash2[5] = __rev(h5);
+    hash2[6] = __rev(h6);
+
+    
+    if(type == SHA_256)
+        hash2[7] = __rev(h7);
+}
+
+void SHA2_32::computeBlock(uint32_t *h02, 
+                        uint32_t *h12, 
+                        uint32_t *h22, 
+                        uint32_t *h32, 
+                        uint32_t *h42, 
+                        uint32_t *h52, 
+                        uint32_t *h62,
+                        uint32_t *h72,
+                        uint8_t *buffer)
+{
+    uint32_t w[16];
+    uint32_t *buffer2 = (uint32_t*)buffer;
+    uint32_t a = *h02, b = *h12, c = *h22, d = *h32, e = *h42, f = *h52, g = *h62, h = *h72;
+    uint32_t T1, T2;
+
+
+    R(a,b,c,d,e,f,g,h,0,0x428a2f98)
+    R(h,a,b,c,d,e,f,g,1,0x71374491)
+    R(g,h,a,b,c,d,e,f,2,0xb5c0fbcf)
+    R(f,g,h,a,b,c,d,e,3,0xe9b5dba5)
+    R(e,f,g,h,a,b,c,d,4,0x3956c25b)
+    R(d,e,f,g,h,a,b,c,5,0x59f111f1)
+    R(c,d,e,f,g,h,a,b,6,0x923f82a4)
+    R(b,c,d,e,f,g,h,a,7,0xab1c5ed5)
+
+    R(a,b,c,d,e,f,g,h,8,0xd807aa98)
+    R(h,a,b,c,d,e,f,g,9,0x12835b01)
+    R(g,h,a,b,c,d,e,f,10,0x243185be)
+    R(f,g,h,a,b,c,d,e,11,0x550c7dc3)
+    R(e,f,g,h,a,b,c,d,12,0x72be5d74)
+    R(d,e,f,g,h,a,b,c,13,0x80deb1fe)
+    R(c,d,e,f,g,h,a,b,14,0x9bdc06a7)
+    R(b,c,d,e,f,g,h,a,15,0xc19bf174)
+
+    R2(a,b,c,d,e,f,g,h,16,0xe49b69c1)
+    R2(h,a,b,c,d,e,f,g,17,0xefbe4786)
+    R2(g,h,a,b,c,d,e,f,18,0x0fc19dc6)
+    R2(f,g,h,a,b,c,d,e,19,0x240ca1cc)
+    R2(e,f,g,h,a,b,c,d,20,0x2de92c6f)
+    R2(d,e,f,g,h,a,b,c,21,0x4a7484aa)
+    R2(c,d,e,f,g,h,a,b,22,0x5cb0a9dc)
+    R2(b,c,d,e,f,g,h,a,23,0x76f988da)
+    
+    R2(a,b,c,d,e,f,g,h,24,0x983e5152)
+    R2(h,a,b,c,d,e,f,g,25,0xa831c66d)
+    R2(g,h,a,b,c,d,e,f,26,0xb00327c8)
+    R2(f,g,h,a,b,c,d,e,27,0xbf597fc7)
+    R2(e,f,g,h,a,b,c,d,28,0xc6e00bf3)
+    R2(d,e,f,g,h,a,b,c,29,0xd5a79147)
+    R2(c,d,e,f,g,h,a,b,30,0x06ca6351)
+    R2(b,c,d,e,f,g,h,a,31,0x14292967) 
+
+    R2(a,b,c,d,e,f,g,h,32,0x27b70a85)
+    R2(h,a,b,c,d,e,f,g,33,0x2e1b2138)
+    R2(g,h,a,b,c,d,e,f,34,0x4d2c6dfc)
+    R2(f,g,h,a,b,c,d,e,35,0x53380d13)
+    R2(e,f,g,h,a,b,c,d,36,0x650a7354)
+    R2(d,e,f,g,h,a,b,c,37,0x766a0abb)
+    R2(c,d,e,f,g,h,a,b,38,0x81c2c92e)
+    R2(b,c,d,e,f,g,h,a,39,0x92722c85)
+    
+    R2(a,b,c,d,e,f,g,h,40,0xa2bfe8a1)
+    R2(h,a,b,c,d,e,f,g,41,0xa81a664b)
+    R2(g,h,a,b,c,d,e,f,42,0xc24b8b70)
+    R2(f,g,h,a,b,c,d,e,43,0xc76c51a3)
+    R2(e,f,g,h,a,b,c,d,44,0xd192e819)
+    R2(d,e,f,g,h,a,b,c,45,0xd6990624)
+    R2(c,d,e,f,g,h,a,b,46,0xf40e3585)
+    R2(b,c,d,e,f,g,h,a,47,0x106aa070)
+    
+    R2(a,b,c,d,e,f,g,h,48,0x19a4c116)
+    R2(h,a,b,c,d,e,f,g,49,0x1e376c08)
+    R2(g,h,a,b,c,d,e,f,50,0x2748774c)
+    R2(f,g,h,a,b,c,d,e,51,0x34b0bcb5)
+    R2(e,f,g,h,a,b,c,d,52,0x391c0cb3)
+    R2(d,e,f,g,h,a,b,c,53,0x4ed8aa4a)
+    R2(c,d,e,f,g,h,a,b,54,0x5b9cca4f)
+    R2(b,c,d,e,f,g,h,a,55,0x682e6ff3)
+    
+    R2(a,b,c,d,e,f,g,h,56,0x748f82ee)
+    R2(h,a,b,c,d,e,f,g,57,0x78a5636f)
+    R2(g,h,a,b,c,d,e,f,58,0x84c87814)
+    R2(f,g,h,a,b,c,d,e,59,0x8cc70208)
+    R2(e,f,g,h,a,b,c,d,60,0x90befffa)
+    R2(d,e,f,g,h,a,b,c,61,0xa4506ceb)
+    R2(c,d,e,f,g,h,a,b,62,0xbef9a3f7)
+    R2(b,c,d,e,f,g,h,a,63,0xc67178f2)
+    
+    
+    *h02 += a;
+    *h12 += b;
+    *h22 += c;
+    *h32 += d;
+    *h42 += e;
+    *h52 += f;
+    *h62 += g;
+    *h72 += h;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA2_32.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,41 @@
+#ifndef SHA2_32_H
+#define SHA2_32_H
+
+#include <stdint.h>
+
+enum SHA_32_TYPE
+{
+    SHA_224,
+    SHA_256
+};
+
+class SHA2_32
+{
+    public :
+    
+        SHA2_32(SHA_32_TYPE type);
+        void update(uint8_t *data, uint32_t length);
+        void finalize(uint8_t *digest);
+        
+        static void computeHash(SHA_32_TYPE type, uint8_t *digest, uint8_t *data, uint32_t length);
+        
+    private : 
+    
+        static void computeBlock(uint32_t *h02, 
+                                 uint32_t *h12, 
+                                 uint32_t *h22, 
+                                 uint32_t *h32, 
+                                 uint32_t *h42, 
+                                 uint32_t *h52, 
+                                 uint32_t *h62,
+                                 uint32_t *h72,
+                                 uint8_t *buffer);
+
+        SHA_32_TYPE type;
+        uint32_t h0, h1, h2, h3, h4, h5, h6, h7;
+        uint32_t totalBufferLength;
+        uint8_t buffer[64];
+        uint8_t bufferLength;   
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA2_64.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,354 @@
+#include "SHA2_64.h"
+#include <string.h>
+
+
+static const uint64_t H[] =
+{
+    // SHA-384
+    0xcbbb9d5dc1059ed8, 0x629a292a367cd507, 0x9159015a3070dd17, 0x152fecd8f70e5939,
+    0x67332667ffc00b31, 0x8eb44a8768581511, 0xdb0c2e0d64f98fa7, 0x47b5481dbefa4fa4,
+
+    // SHA-512
+    0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,
+    0x510e527fade682d1, 0x9b05688c2b3e6c1f, 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179
+};
+
+static uint64_t revWord(uint64_t w)
+{
+    return __rev(w >> 32) 
+         | ((uint64_t)(__rev(w)) << 32);
+}
+
+#define ROTL(W,N) (((W) << (N)) | ((W) >> (64-(N))))
+#define ROTR(W,N) (((W) >> (N)) | ((W) << (64-(N))))
+#define CH(X,Y,Z) (((X) & (Y)) ^ ((~(X)) & (Z)))
+#define MAJ(X,Y,Z) (((X) & (Y)) ^ ((X) & (Z)) ^ ((Y) & (Z)))
+#define BSIG0(X) (ROTR(X,28) ^ ROTR(X,34) ^ ROTR(X,39))
+#define BSIG1(X) (ROTR(X,14) ^ ROTR(X,18) ^ ROTR(X,41))
+#define SSIG0(X) (ROTR((X),1) ^ ROTR((X),8) ^ ((X) >> 7))
+#define SSIG1(X) (ROTR((X),19) ^ ROTR((X),61) ^ ((X) >> 6))
+
+#define R(A,B,C,D,E,F,G,H,K,T)  T1 = H + BSIG1(E) + CH(E,F,G) + K + w[T]; \
+                              T2 = BSIG0(A) + MAJ(A,B,C); \
+                              D += T1; \
+                              H = T1 + T2;    
+                          
+
+SHA2_64::SHA2_64(SHA2_64_TYPE t):
+type(t),
+totalBufferLength(0),
+bufferLength(0)
+{
+    switch(type)
+    {
+        case SHA_384:
+            h0 = H[0];
+            h1 = H[1];
+            h2 = H[2];
+            h3 = H[3];
+            h4 = H[4];
+            h5 = H[5];
+            h6 = H[6];
+            h7 = H[7];
+        break;
+        
+        case SHA_512:
+            h0 = H[8];
+            h1 = H[9];
+            h2 = H[10];
+            h3 = H[11];
+            h4 = H[12];
+            h5 = H[13];
+            h6 = H[14];
+            h7 = H[15];     
+        break;
+    }
+}
+
+void SHA2_64::update(uint8_t *data, uint32_t length)
+{
+    if(length < 128-bufferLength)
+    {
+        memcpy(&buffer[bufferLength], data, length);
+        bufferLength += length;
+        totalBufferLength += length;
+        return;
+    }
+    int offset = 128-bufferLength;
+    memcpy(&buffer[bufferLength], data, offset);
+    computeBlock(&h0,&h1,&h2,&h3,&h4,&h5,&h6,&h7,buffer);
+    while(length-offset > 128)
+    {
+        memcpy(buffer, &data[offset], 128);
+        computeBlock(&h0,&h1,&h2,&h3,&h4,&h5,&h6,&h7,buffer);
+        offset += 128;
+    }
+    if(offset > length)
+        offset -= 128;
+    bufferLength = length - offset;
+    memcpy(buffer, &data[offset], bufferLength);
+    totalBufferLength += length;
+}
+
+void SHA2_64::finalize(uint8_t *hash)
+{
+    uint64_t *hash2 = (uint64_t*)hash;
+    uint64_t lengthBit = totalBufferLength << 3;
+    uint32_t padding;
+    if(totalBufferLength % 128 < 112)
+        padding = 112 - (totalBufferLength % 128);
+    else
+        padding = 112 + (128 - (totalBufferLength % 128));
+
+    buffer[bufferLength++] = 0x80;
+    padding--;
+    if(padding+bufferLength == 112)
+        memset(&buffer[bufferLength], 0, padding);
+    else
+    {
+        memset(&buffer[bufferLength], 0, 64-bufferLength);
+        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
+        memset(buffer, 0, 112);
+    }
+    
+    lengthBit = revWord(lengthBit);
+    memcpy(&buffer[120], &lengthBit, 8);    
+    memset(&buffer[112], 0, 8);    
+    computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
+
+
+    hash2[0] = revWord(h0);
+    hash2[1] = revWord(h1);
+    hash2[2] = revWord(h2);
+    hash2[3] = revWord(h3);
+    hash2[4] = revWord(h4);
+    hash2[5] = revWord(h5);
+
+
+    if(type == SHA_512)
+    {
+        hash2[6] = revWord(h6);
+        hash2[7] = revWord(h7);
+    }
+    
+    // reset state
+    switch(type)
+    {
+        case SHA_384:
+            h0 = H[0];
+            h1 = H[1];
+            h2 = H[2];
+            h3 = H[3];
+            h4 = H[4];
+            h5 = H[5];
+            h6 = H[6];
+            h7 = H[7];
+        break;
+        
+        case SHA_512:
+            h0 = H[8];
+            h1 = H[9];
+            h2 = H[10];
+            h3 = H[11];
+            h4 = H[12];
+            h5 = H[13];
+            h6 = H[14];
+            h7 = H[15];     
+        break;
+    }
+    totalBufferLength = 0;
+    bufferLength = 0;
+}
+
+void SHA2_64::computeHash(SHA2_64_TYPE type, uint8_t *hash, uint8_t *data, uint32_t length)
+{
+    uint64_t *hash2 = (uint64_t*)hash;
+    uint64_t lengthBit = length * 8;
+    uint64_t h0 = H[type*8], h1 = H[type*8+1], h2 = H[type*8+2], h3 = H[type*8+3];
+    uint64_t h4 = H[type*8+4], h5 = H[type*8+5], h6 = H[type*8+6], h7 = H[type*8+7];
+    
+    int padding;
+    if(length % 128 < 112)
+        padding = 112 - (length % 128);
+    else
+        padding = 112 + (128 - (length % 128));
+        
+    while(length >= 128)
+    {
+        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, data);
+        data += 128;
+        length -= 128;
+    }
+    uint8_t buffer[128];
+    memcpy(buffer, data,length); 
+    buffer[length] = 0x80;
+    length++;
+    padding--;
+
+    if(padding+length == 112)
+        memset(&buffer[length], 0, padding);
+    else
+    {
+        memset(&buffer[length], 0, 128-length);
+        computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
+        memset(buffer, 0, 112);
+    }
+    
+    lengthBit = revWord(lengthBit);
+    memset(&buffer[112], 0, 8); 
+    memcpy(&buffer[120], &lengthBit, 8);
+    computeBlock(&h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, buffer);
+
+    hash2[0] = revWord(h0);
+    hash2[1] = revWord(h1);
+    hash2[2] = revWord(h2);
+    hash2[3] = revWord(h3);
+    hash2[4] = revWord(h4);
+    hash2[5] = revWord(h5);
+
+
+    if(type == SHA_512)
+    {
+        hash2[6] = revWord(h6);
+        hash2[7] = revWord(h7);
+    }
+}
+
+void SHA2_64::computeBlock(uint64_t *h02, 
+                     uint64_t *h12, 
+                     uint64_t *h22, 
+                     uint64_t *h32, 
+                     uint64_t *h42, 
+                     uint64_t *h52, 
+                     uint64_t *h62,
+                     uint64_t *h72,
+                     uint8_t *buffer)
+{
+    uint64_t w[80];
+    uint64_t *buffer2 = (uint64_t*)buffer;
+
+    w[0] = revWord(buffer2[0]);
+    w[1] = revWord(buffer2[1]);
+    w[2] = revWord(buffer2[2]);
+    w[3] = revWord(buffer2[3]);
+    w[4] = revWord(buffer2[4]);
+    w[5] = revWord(buffer2[5]);
+    w[6] = revWord(buffer2[6]);
+    w[7] = revWord(buffer2[7]); 
+    w[8] = revWord(buffer2[8]);
+    w[9] = revWord(buffer2[9]);
+    w[10] = revWord(buffer2[10]);
+    w[11] = revWord(buffer2[11]);
+    w[12] = revWord(buffer2[12]);
+    w[13] = revWord(buffer2[13]);
+    w[14] = revWord(buffer2[14]);
+    w[15] = revWord(buffer2[15]);     
+    
+    for(int t = 16; t < 80; ++t)
+        w[t] = SSIG1(w[t-2]) + w[t-7] + SSIG0(w[t-15]) + w[t-16];
+    
+    uint64_t a = *h02, b = *h12, c = *h22, d = *h32, e = *h42, f = *h52, g = *h62, h = *h72;
+    uint64_t T1, T2;
+    
+
+    R(a,b,c,d,e,f,g,h,0x428a2f98d728ae22,0)
+    R(h,a,b,c,d,e,f,g,0x7137449123ef65cd,1)
+    R(g,h,a,b,c,d,e,f,0xb5c0fbcfec4d3b2f,2)
+    R(f,g,h,a,b,c,d,e,0xe9b5dba58189dbbc,3)
+    R(e,f,g,h,a,b,c,d,0x3956c25bf348b538,4)
+    R(d,e,f,g,h,a,b,c,0x59f111f1b605d019,5)
+    R(c,d,e,f,g,h,a,b,0x923f82a4af194f9b,6)
+    R(b,c,d,e,f,g,h,a,0xab1c5ed5da6d8118,7)
+
+    R(a,b,c,d,e,f,g,h,0xd807aa98a3030242,8)
+    R(h,a,b,c,d,e,f,g,0x12835b0145706fbe,9)
+    R(g,h,a,b,c,d,e,f,0x243185be4ee4b28c,10)
+    R(f,g,h,a,b,c,d,e,0x550c7dc3d5ffb4e2,11)
+    R(e,f,g,h,a,b,c,d,0x72be5d74f27b896f,12)
+    R(d,e,f,g,h,a,b,c,0x80deb1fe3b1696b1,13)
+    R(c,d,e,f,g,h,a,b,0x9bdc06a725c71235,14)
+    R(b,c,d,e,f,g,h,a,0xc19bf174cf692694,15)
+    
+    
+    R(a,b,c,d,e,f,g,h,0xe49b69c19ef14ad2,16)
+    R(h,a,b,c,d,e,f,g,0xefbe4786384f25e3,17)
+    R(g,h,a,b,c,d,e,f,0x0fc19dc68b8cd5b5,18)
+    R(f,g,h,a,b,c,d,e,0x240ca1cc77ac9c65,19)
+    R(e,f,g,h,a,b,c,d,0x2de92c6f592b0275,20)
+    R(d,e,f,g,h,a,b,c,0x4a7484aa6ea6e483,21)
+    R(c,d,e,f,g,h,a,b,0x5cb0a9dcbd41fbd4,22)
+    R(b,c,d,e,f,g,h,a,0x76f988da831153b5,23)
+    
+    R(a,b,c,d,e,f,g,h,0x983e5152ee66dfab,24)
+    R(h,a,b,c,d,e,f,g,0xa831c66d2db43210,25)
+    R(g,h,a,b,c,d,e,f,0xb00327c898fb213f,26)
+    R(f,g,h,a,b,c,d,e,0xbf597fc7beef0ee4,27)
+    R(e,f,g,h,a,b,c,d,0xc6e00bf33da88fc2,28)
+    R(d,e,f,g,h,a,b,c,0xd5a79147930aa725,29)
+    R(c,d,e,f,g,h,a,b,0x06ca6351e003826f,30)
+    R(b,c,d,e,f,g,h,a,0x142929670a0e6e70,31) 
+    
+    
+    R(a,b,c,d,e,f,g,h,0x27b70a8546d22ffc,32)
+    R(h,a,b,c,d,e,f,g,0x2e1b21385c26c926,33)
+    R(g,h,a,b,c,d,e,f,0x4d2c6dfc5ac42aed,34)
+    R(f,g,h,a,b,c,d,e,0x53380d139d95b3df,35)
+    R(e,f,g,h,a,b,c,d,0x650a73548baf63de,36)
+    R(d,e,f,g,h,a,b,c,0x766a0abb3c77b2a8,37)
+    R(c,d,e,f,g,h,a,b,0x81c2c92e47edaee6,38)
+    R(b,c,d,e,f,g,h,a,0x92722c851482353b,39)
+    
+    R(a,b,c,d,e,f,g,h,0xa2bfe8a14cf10364,40)
+    R(h,a,b,c,d,e,f,g,0xa81a664bbc423001,41)
+    R(g,h,a,b,c,d,e,f,0xc24b8b70d0f89791,42)
+    R(f,g,h,a,b,c,d,e,0xc76c51a30654be30,43)
+    R(e,f,g,h,a,b,c,d,0xd192e819d6ef5218,44)
+    R(d,e,f,g,h,a,b,c,0xd69906245565a910,45)
+    R(c,d,e,f,g,h,a,b,0xf40e35855771202a,46)
+    R(b,c,d,e,f,g,h,a,0x106aa07032bbd1b8,47)
+
+    R(a,b,c,d,e,f,g,h,0x19a4c116b8d2d0c8,48)
+    R(h,a,b,c,d,e,f,g,0x1e376c085141ab53,49)
+    R(g,h,a,b,c,d,e,f,0x2748774cdf8eeb99,50)
+    R(f,g,h,a,b,c,d,e,0x34b0bcb5e19b48a8,51)
+    R(e,f,g,h,a,b,c,d,0x391c0cb3c5c95a63,52)
+    R(d,e,f,g,h,a,b,c,0x4ed8aa4ae3418acb,53)
+    R(c,d,e,f,g,h,a,b,0x5b9cca4f7763e373,54)
+    R(b,c,d,e,f,g,h,a,0x682e6ff3d6b2b8a3,55)
+    
+    R(a,b,c,d,e,f,g,h,0x748f82ee5defb2fc,56)
+    R(h,a,b,c,d,e,f,g,0x78a5636f43172f60,57)
+    R(g,h,a,b,c,d,e,f,0x84c87814a1f0ab72,58)
+    R(f,g,h,a,b,c,d,e,0x8cc702081a6439ec,59)
+    R(e,f,g,h,a,b,c,d,0x90befffa23631e28,60)
+    R(d,e,f,g,h,a,b,c,0xa4506cebde82bde9,61)
+    R(c,d,e,f,g,h,a,b,0xbef9a3f7b2c67915,62)
+    R(b,c,d,e,f,g,h,a,0xc67178f2e372532b,63)
+
+    R(a,b,c,d,e,f,g,h,0xca273eceea26619c,64)
+    R(h,a,b,c,d,e,f,g,0xd186b8c721c0c207,65)
+    R(g,h,a,b,c,d,e,f,0xeada7dd6cde0eb1e,66)
+    R(f,g,h,a,b,c,d,e,0xf57d4f7fee6ed178,67)
+    R(e,f,g,h,a,b,c,d,0x06f067aa72176fba,68)
+    R(d,e,f,g,h,a,b,c,0x0a637dc5a2c898a6,69)
+    R(c,d,e,f,g,h,a,b,0x113f9804bef90dae,70)
+    R(b,c,d,e,f,g,h,a,0x1b710b35131c471b,71)
+
+    R(a,b,c,d,e,f,g,h,0x28db77f523047d84,72)
+    R(h,a,b,c,d,e,f,g,0x32caab7b40c72493,73)
+    R(g,h,a,b,c,d,e,f,0x3c9ebe0a15c9bebc,74)
+    R(f,g,h,a,b,c,d,e,0x431d67c49c100d4c,75)
+    R(e,f,g,h,a,b,c,d,0x4cc5d4becb3e42b6,76)
+    R(d,e,f,g,h,a,b,c,0x597f299cfc657e2a,77)
+    R(c,d,e,f,g,h,a,b,0x5fcb6fab3ad6faec,78)
+    R(b,c,d,e,f,g,h,a,0x6c44198c4a475817,79)
+            
+    *h02 += a;
+    *h12 += b;
+    *h22 += c;
+    *h32 += d;
+    *h42 += e;
+    *h52 += f;
+    *h62 += g;
+    *h72 += h;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA2_64.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,42 @@
+#ifndef SHA2_64_H
+#define SHA2_64_H
+
+#include <stdint.h>
+
+enum SHA2_64_TYPE
+{
+    SHA_384,
+    SHA_512
+};
+
+class SHA2_64
+{
+    public :
+
+        SHA2_64(SHA2_64_TYPE type);
+        
+        void update(uint8_t *data, uint32_t length);
+        void finalize(uint8_t *hash);
+        
+        static void computeHash(SHA2_64_TYPE type, uint8_t *hash, uint8_t *data, uint32_t length);
+
+    private :
+    
+            static void computeBlock(uint64_t *h02, 
+                                 uint64_t *h12, 
+                                 uint64_t *h22, 
+                                 uint64_t *h32, 
+                                 uint64_t *h42, 
+                                 uint64_t *h52, 
+                                 uint64_t *h62,
+                                 uint64_t *h72,
+                                 uint8_t *buffer);
+                                 
+        SHA2_64_TYPE type;
+        uint64_t h0, h1, h2, h3, h4, h5, h6, h7;
+        uint32_t totalBufferLength;
+        uint8_t buffer[128];
+        uint8_t bufferLength;        
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA384.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,28 @@
+#include "SHA384.h"
+
+
+SHA384::SHA384():
+HashAlgorithm(),
+algo(SHA_384)
+{
+}
+
+uint8_t SHA384::outputSize() const
+{
+    return 48;
+}
+
+void SHA384::update(uint8_t *data, uint32_t length)
+{
+    algo.update(data, length);
+}
+
+void SHA384::finalize(uint8_t *hash)
+{
+    algo.finalize(hash);
+}
+
+void SHA384::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
+{
+    SHA2_64::computeHash(SHA_384, hash, data, length);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA384.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,25 @@
+#ifndef SHA2_384_H
+#define SHA2_384_H
+
+#include "HashAlgorithm.h"
+#include "SHA2_64.h"
+
+
+class SHA384 : public HashAlgorithm
+{
+    public :
+
+        SHA384();
+        
+        virtual uint8_t outputSize() const;
+        virtual void update(uint8_t *data, uint32_t length);
+        virtual void finalize(uint8_t *hash);
+
+        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
+
+    private :
+    
+        SHA2_64 algo;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA512.cpp	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,28 @@
+#include "SHA512.h"
+
+
+SHA512::SHA512():
+HashAlgorithm(),
+algo(SHA_512)
+{
+}
+
+uint8_t SHA512::outputSize() const
+{
+    return 64;
+}
+
+void SHA512::update(uint8_t *data, uint32_t length)
+{
+    algo.update(data, length);
+}
+
+void SHA512::finalize(uint8_t *hash)
+{
+    algo.finalize(hash);
+}
+
+void SHA512::computeHash(uint8_t *hash, uint8_t *data, uint32_t length)
+{
+    SHA2_64::computeHash(SHA_512, hash, data, length);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hash/SHA512.h	Sat Sep 14 18:21:32 2013 +0000
@@ -0,0 +1,25 @@
+#ifndef SHA2_512_H
+#define SHA2_512_H
+
+#include "HashAlgorithm.h"
+#include "SHA2_64.h"
+
+
+class SHA512 : public HashAlgorithm
+{
+    public :
+
+        SHA512();
+        
+        virtual uint8_t outputSize() const;
+        virtual void update(uint8_t *data, uint32_t length);
+        virtual void finalize(uint8_t *hash);
+
+        static void computeHash(uint8_t *hash, uint8_t *data, uint32_t length);
+
+    private :
+    
+        SHA2_64 algo;
+};
+
+#endif