Were can i find the MD5 include?
#1

Can someone help me please? :P
Reply
#2

Search.
Reply
#3

It's in SeifAdmin too..
Reply
#4

PHP Code:
/*----------------------------------------------------------------------------*-
                    ===========================
                    Y Sever Includes - MD5 Core
                    ===========================
Description:
    Provides an implementation of the MD5 hashing algorithmfor PAWN, either for
    efficient and progressive hashing of chunks of data or just a straight hash
    of a single string.
Legal:
    The algorithm is due to Ron Rivest.  This code was
    written by Colin Plumb in 1993, no copyright is claimed.
    This code is in the public domain; do with it what you wish.
    Equivalent code is available from RSA Data Security, Inc.
    This code has been tested against that, and is equivalent,
    except that you don't need to include two pages of legalese
    with every copy.
    Converted to PAWN by Alex "******" Cole.
Version:
    0.1
Changelog:
    26/12/07:
        First version.
Functions:
    Public:
        -
    Core:
        -
    Stock:
        MD5_Hash - Takes a string and returns a 16 cell hash.
        MD5_Init - Initialises a hash structure.
        MD5_Update - Appends data to the hash in progress.
        MD5_Copy - Custom pack function.
        MD5_Final - Finalises a hash.
        MD5_File - Hashes a file incrementally.
        MD5_Data - Hashes binary data, not just strings.
    Static:
        MD5_Transform - Does the data mixing.
    Inline:
        MD5_Step - Does a single hash step.
    API:
        -
Callbacks:
    -
Definitions:
    -
Enums:
    E_MD5_CONTEXT - Data structure for an in progress hashing.
Macros:
    MD5_F1 - First hash part.
    MD5_F2 - Second hash part.
    MD5_F3 - Third hash part.
    MD5_F4 - Fourth hash part.
Tags:
    -
Variables:
    Global:
        -
    Static:
        -
Commands:
    -
Compile options:
    -
-*----------------------------------------------------------------------------*/
enum E_MD5_CONTEXT
{
    
E_MD5_CONTEXT_BUF[4],
    
E_MD5_CONTEXT_BITS[2],
    
E_MD5_CONTEXT_IN[64 char]
}
#define MD5_F1(%1,%2,%3) (%3 ^ (%1 & (%2 ^ %3)))
#define MD5_F2(%1,%2,%3) MD5_F1(%3, %1, %2)
#define MD5_F3(%1,%2,%3) (%1 ^ %2 ^ %3)
#define MD5_F4(%1,%2,%3) (%2 ^ (%1 | ~%3))
/*----------------------------------------------------------------------------*-
Function:
    MD5_Hash
Params:
    str[] - String to hash.
Return:
    String representation of the hash.
Notes:
    The simplest way to hash a string, simply pass a string and get a 4 cell
    hash returned.
-*----------------------------------------------------------------------------*/
stock MD5_Hash(str[])
{
    new
        
md5Data[E_MD5_CONTEXT],
        
done,
        
digest[34],
        
len strlen(str);
    
MD5_Init(md5Data);
    
len -= 64;
    while (
done len)
    {
        
MD5_Update(md5Datastr[done], 64);
        
done += 64;
    }
    
len = (len 64) - done;
    if (
len)
    {
        
MD5_Update(md5Datastr[done], len);
    }
    
digest MD5_Final(md5Datatrue);
    return 
digest;
}
/*----------------------------------------------------------------------------*-
Function:
    MD5_Data
Params:
    data[] - Binary data to hash.
    len - Length of data to hash.
Return:
    String representation of the hash.
Notes:
    Hashes binary data, not just strings.
-*----------------------------------------------------------------------------*/
stock MD5_Data(data[], len)
{
    new
        
md5Data[E_MD5_CONTEXT],
        
done,
        
digest[33];
    
MD5_Init(md5Data);
    
len -= 64;
    while (
done len)
    {
        
MD5_Update(md5Datadata[done], 64);
        
done += 64;
    }
    
len = (len 64) - done;
    if (
len)
    {
        
MD5_Update(md5Datadata[done], len);
    }
    
digest MD5_Final(md5Datatrue);
    return 
digest;
}
/*----------------------------------------------------------------------------*-
Function:
    MD5_File
Params:
    filename[] - File to hash.
Return:
    -
Notes:
    Hashes the file incrementally, not in one huge chunk.
-*----------------------------------------------------------------------------*/
stock MD5_File(filename[])
{
    new
        
digest[33],
        
File:fHnd fopen(filenameio_read);
    if (
fHnd)
    {
        new
            
md5Data[E_MD5_CONTEXT],
            
data[64],
            
len;
        
MD5_Init(md5Data);
        
MD5_File_loop:
        
len fblockread(fHnddata);
        if (
len)
        {
            
MD5_Update(md5Datadatalen);
            goto 
MD5_File_loop;
        }
        
digest MD5_Final(md5Datatrue);
        
fclose(fHnd);
    }
    return 
digest;
}
/*----------------------------------------------------------------------------*-
Function:
    MD5_Init
Params:
    ctx[E_MD5_CONTEXT] - Hash data.
Return:
    -
Notes:
    Sets up the data for hashing.
-*----------------------------------------------------------------------------*/
stock MD5_Init(ctx[E_MD5_CONTEXT])
{
    
ctx[E_MD5_CONTEXT_BUF][0] = 0x67452301;
    
ctx[E_MD5_CONTEXT_BUF][1] = 0xEFCDAB89;
    
ctx[E_MD5_CONTEXT_BUF][2] = 0x98BADCFE;
    
ctx[E_MD5_CONTEXT_BUF][3] = 0x10325476;
    
ctx[E_MD5_CONTEXT_BITS][0] = 0;
    
ctx[E_MD5_CONTEXT_BITS][1] = 0;
}
/*----------------------------------------------------------------------------*-
Function:
    MD5_Update
Params:
    ctx[E_MD5_CONTEXT] - Hash data.
    data[] - String to append.
    len - Length of string to append.
Return:
    -
Notes:
    Adds data to the current hash.
-*----------------------------------------------------------------------------*/
stock MD5_Update(ctx[E_MD5_CONTEXT], data[], len)
{
    new
        
ctx[E_MD5_CONTEXT_BITS][0],
        
s,
        
buf 0;
    if ((
ctx[E_MD5_CONTEXT_BITS][0] = + (len << 3)) < t)
    {
        
ctx[E_MD5_CONTEXT_BITS][1]++;
    }
    
ctx[E_MD5_CONTEXT_BITS][1] += len >>> 29;
    
= (>>> 3) & 0x3F;
    if (
t)
    {
        
64 t;
        if (
len s)
        {
            
MD5_Copy(ctx[E_MD5_CONTEXT_IN], datatlen);
            return;
        }
        
MD5_Copy(ctx[E_MD5_CONTEXT_IN], datats);
        
MD5_Transform(ctx[E_MD5_CONTEXT_BUF], ctx[E_MD5_CONTEXT_IN]);
        
buf += s;
        
len -= s;
    }
    while (
len >= 64)
    {
        
MD5_Copy(ctx[E_MD5_CONTEXT_IN], data[buf], 064);
        
MD5_Transform(ctx[E_MD5_CONTEXT_BUF], ctx[E_MD5_CONTEXT_IN]);
        
buf += 64;
        
len -= 64;
    }
    
MD5_Copy(ctx[E_MD5_CONTEXT_IN], data[buf], 0len);
}
/*----------------------------------------------------------------------------*-
Function:
    MD5_Copy
Params:
    dest[] - Packed destination array.
    src[] - Unpacked source array.
    start - Start BYTE in the dest array.
    len - Length of data to copy.
Return:
    -
Notes:
    Custom strpack implementation allowing offset starts.
-*----------------------------------------------------------------------------*/
stock MD5_Copy(dest[], src[], startlen)
{
    new
        
start >>> 2,
        
0,
        
ch;
    while (
len)
    {
        
ch src[j++] & 0xFF;
        switch (
start++ & 0x03)
        {
            case 
0:
            {
                
dest[i] = ch;
            }
            case 
1:
            {
                
dest[i] |= ch << 8;
            }
            case 
2:
            {
                
dest[i] |= ch << 16;
            }
            case 
3:
            {
                
dest[i++] |= ch << 24;
            }
        }
    }
}
/*----------------------------------------------------------------------------*-
Function:
    MD5_Final
Params:
    ctx[E_MD5_CONTEXT] - Hash data.
    string - Wehter or not to create a string version of the hash.
Return:
    -
Notes:
    Terminates the pending data, appends the length and finishes hashing.
-*----------------------------------------------------------------------------*/
stock MD5_Final(ctx[E_MD5_CONTEXT], string false)
{
    new
        
count,
        
index,
        
digest[33];
    
count = (ctx[E_MD5_CONTEXT_BITS][0] >>> 3) & 0x3F;
    if (!(
count 0x03))
    {
        
ctx[E_MD5_CONTEXT_IN][count 4] = 0;
    }
    
ctx[E_MD5_CONTEXT_IN][count 4] |= (0x80 << (* (count 0x03)));
    
index = (count 4) + 1;
    
count 64 count;
    if (
count 8)
    {
        while (
index 64 char)
        {
            
ctx[E_MD5_CONTEXT_IN][index++] = 0;
        }
        
MD5_Transform(ctx[E_MD5_CONTEXT_BUF], ctx[E_MD5_CONTEXT_IN]);
        
index 0;
        while (
index 56 char)
        {
            
ctx[E_MD5_CONTEXT_IN][index++] = 0;
        }
    }
    else
    {
        while (
index 56 char)
        {
            
ctx[E_MD5_CONTEXT_IN][index++] = 0;
        }
    }
    
ctx[E_MD5_CONTEXT_IN][14] = ctx[E_MD5_CONTEXT_BITS][0];
    
ctx[E_MD5_CONTEXT_IN][15] = ctx[E_MD5_CONTEXT_BITS][1];
    
MD5_Transform(ctx[E_MD5_CONTEXT_BUF], ctx[E_MD5_CONTEXT_IN]);
    if (string)
    {
        
index 0;
        do
        {
            
format(digestsizeof (digest), "%s%02x"digest, (ctx[E_MD5_CONTEXT_BUF][index 4] >> ((index 0x03) * 8)) & 0xFF);
        }
        while (++
index 16);
    }
    return 
digest;
}
/*----------------------------------------------------------------------------*-
Function:
    MD5_Step
Params:
    func - Hash function to use.
    a - Data cell 1.
    b - Data cell 2.
    c - Data cell 3.
    d - Data cell 4.
    data - New input.
    s - Seed.
Return:
    -
Notes:
    Does a single hash step.
-*----------------------------------------------------------------------------*/
#define MD5_Step(%1,%2,%3,%4,%5,%6,%7) \
    
%+= %1(%3, %4, %5) + %6, %= %<< %| %>>> (32 - %7), %+= %3
/*----------------------------------------------------------------------------*-
Function:
    MD5_Transform
Params:
    buf[] - Current hash.
    in[] - New data.
Return:
    -
Notes:
    Does the hashing steps on the current data.
-*----------------------------------------------------------------------------*/
static stock MD5_Transform(buf[], in[])
{
    new
        
buf[0],
        
buf[1],
        
buf[2],
        
buf[3];
    
#pragma tabsize 4
    
MD5_Step(MD5_F1abcdin[0]  + 0xD76AA4787);
    
MD5_Step(MD5_F1dabcin[1]  + 0xE8C7B75612);
    
MD5_Step(MD5_F1cdabin[2]  + 0x242070DB17);
    
MD5_Step(MD5_F1bcdain[3]  + 0xC1BDCEEE22);
    
MD5_Step(MD5_F1abcdin[4]  + 0xF57C0FAF7);
    
MD5_Step(MD5_F1dabcin[5]  + 0x4787C62A12);
    
MD5_Step(MD5_F1cdabin[6]  + 0xA830461317);
    
MD5_Step(MD5_F1bcdain[7]  + 0xFD46950122);
    
MD5_Step(MD5_F1abcdin[8]  + 0x698098D87);
    
MD5_Step(MD5_F1dabcin[9]  + 0x8B44F7AF12);
    
MD5_Step(MD5_F1cdabin[10] + 0xFFFF5BB117);
    
MD5_Step(MD5_F1bcdain[11] + 0x895CD7BE22);
    
MD5_Step(MD5_F1abcdin[12] + 0x6B9011227);
    
MD5_Step(MD5_F1dabcin[13] + 0xFD98719312);
    
MD5_Step(MD5_F1cdabin[14] + 0xA679438E17);
    
MD5_Step(MD5_F1bcdain[15] + 0x49B4082122);
    
MD5_Step(MD5_F2abcdin[1]  + 0xF61E25625);
    
MD5_Step(MD5_F2dabcin[6]  + 0xC040B3409);
    
MD5_Step(MD5_F2cdabin[11] + 0x265E5A5114);
    
MD5_Step(MD5_F2bcdain[0]  + 0xE9B6C7AA20);
    
MD5_Step(MD5_F2abcdin[5]  + 0xD62F105D5);
    
MD5_Step(MD5_F2dabcin[10] + 0x024414539);
    
MD5_Step(MD5_F2cdabin[15] + 0xD8A1E68114);
    
MD5_Step(MD5_F2bcdain[4]  + 0xE7D3FBC820);
    
MD5_Step(MD5_F2abcdin[9]  + 0x21E1CDE65);
    
MD5_Step(MD5_F2dabcin[14] + 0xC33707D69);
    
MD5_Step(MD5_F2cdabin[3]  + 0xF4D50D8714);
    
MD5_Step(MD5_F2bcdain[8]  + 0x455A14ED20);
    
MD5_Step(MD5_F2abcdin[13] + 0xA9E3E9055);
    
MD5_Step(MD5_F2dabcin[2]  + 0xFCEFA3F89);
    
MD5_Step(MD5_F2cdabin[7]  + 0x676F02D914);
    
MD5_Step(MD5_F2bcdain[12] + 0x8D2A4C8A20);
    
MD5_Step(MD5_F3abcdin[5]  + 0xFFFA39424);
    
MD5_Step(MD5_F3dabcin[8]  + 0x8771F68111);
    
MD5_Step(MD5_F3cdabin[11] + 0x6D9D612216);
    
MD5_Step(MD5_F3bcdain[14] + 0xFDE5380C23);
    
MD5_Step(MD5_F3abcdin[1]  + 0xA4BEEA444);
    
MD5_Step(MD5_F3dabcin[4]  + 0x4BDECFA911);
    
MD5_Step(MD5_F3cdabin[7]  + 0xF6BB4B6016);
    
MD5_Step(MD5_F3bcdain[10] + 0xBEBFBC7023);
    
MD5_Step(MD5_F3abcdin[13] + 0x289B7EC64);
    
MD5_Step(MD5_F3dabcin[0]  + 0xEAA127FA11);
    
MD5_Step(MD5_F3cdabin[3]  + 0xD4EF308516);
    
MD5_Step(MD5_F3bcdain[6]  + 0x04881D0523);
    
MD5_Step(MD5_F3abcdin[9]  + 0xD9D4D0394);
    
MD5_Step(MD5_F3dabcin[12] + 0xE6DB99E511);
    
MD5_Step(MD5_F3cdabin[15] + 0x1FA27CF816);
    
MD5_Step(MD5_F3bcdain[2]  + 0xC4AC566523);
    
MD5_Step(MD5_F4abcdin[0]  + 0xF42922446);
    
MD5_Step(MD5_F4dabcin[7]  + 0x432AFF9710);
    
MD5_Step(MD5_F4cdabin[14] + 0xAB9423A715);
    
MD5_Step(MD5_F4bcdain[5]  + 0xFC93A03921);
    
MD5_Step(MD5_F4abcdin[12] + 0x655B59C36);
    
MD5_Step(MD5_F4dabcin[3]  + 0x8F0CCC9210);
    
MD5_Step(MD5_F4cdabin[10] + 0xFFEFF47D15);
    
MD5_Step(MD5_F4bcdain[1]  + 0x85845DD121);
    
MD5_Step(MD5_F4abcdin[8]  + 0x6FA87E4F6);
    
MD5_Step(MD5_F4dabcin[15] + 0xFE2CE6E010);
    
MD5_Step(MD5_F4cdabin[6]  + 0xA301431415);
    
MD5_Step(MD5_F4bcdain[13] + 0x4E0811A121);
    
MD5_Step(MD5_F4abcdin[4]  + 0xF7537E826);
    
MD5_Step(MD5_F4dabcin[11] + 0xBD3AF23510);
    
MD5_Step(MD5_F4cdabin[2]  + 0x2AD7D2BB15);
    
MD5_Step(MD5_F4bcdain[9]  + 0xEB86D39121);
    
#pragma tabsize 4
    
buf[0] += a;
    
buf[1] += b;
    
buf[2] += c;
    
buf[3] += d;

Or download from attach.
Reply
#5

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)