001
/**
002
* Creator: WangBin, 2009-11-26
003
* For encrypt...
004
* I cant't verify those code, What the fuck 0f 3des, Make me always get the different result.Bad thing is the memory, should be careful of those free.
005
*
006
* Need To Notice: When you get the return NULL, means wrong; Remember free memory you get from the return.
007
* How To:
008
* 1.Four parameters: str1, ID, TimeStamp, 3DesKey.
009
3DesKey should be initialied as array,like "unsigned char key[24] ={0x2C, 0x7A, 0x0E, 0x98, 0xF1, 0xE0, 0x76, 0x49, 0x73, 0x15, 0xCD, 0x25, 0xE0, 0xB5, 0x43, 0xCB, 0x0E, 0x80, 0x76, 0x01, 0x7F, 0x23, 0x8A, 0x46};"(I needn't convert them). should not be a string!!
010
011
* Find some memory leaf, Be sure the proccess context is killed!
012
*/
013
014
#include <stdlib.h>
015
#include <string.h>
016
#include <stdio.h>
017
#include <XXX/base64.h>
018
#include <openssl/evp.h>
019
#include <openssl/sha.h>
020
#include <openssl/des.h>
021
#include "encrypt.h"
022
#define MAX_URL_LEN 2048
023
#define DES3_BYTE 8
024
#define DES3_PKCS7
025
026
typedef
unsigned
char
uchar;
027
028
uchar *sha1_encode(uchar *src)
029
{
030
SHA_CTX c;
031
uchar *dest = (uchar *)
malloc
((SHA_DIGEST_LENGTH + 1)*
sizeof
(uchar));
032
memset
(dest, 0, SHA_DIGEST_LENGTH + 1);
033
if
(!SHA1_Init(&c))
034
{
035
free
(dest);
036
return
NULL;
037
}
038
SHA1_Update(&c, src,
strlen
(src));
039
SHA1_Final(dest,&c);
040