/******************************************************************************* * FUNCTION NAME : HelperRC4(Char* sIn, UInt32 iInLen, Char* sKey, UInt32 iKeyLen) * DESCRIPTION : Encrypts (in place) the data pointed to by sIn using the * encryption key pointed to by sKey * RETURNS : none * PARAMETERS : sIn - pointer to the data to encrypt * iInLen - Number of bytes to encrypt * sKey - pointer to the encryption key * iKeyLen - Number of bytes in the encryption key * PRECONDITION : none * POSTCONDITION : none * COMMENTS : RC4 encryption is reversible. ie: use the same function again * to decrypt the string. *******************************************************************************/ void HelperRC4(Char * sIn, UInt32 iInLen, Char * sKey, UInt32 iKeyLen) {
UInt8 *inp = (UInt8 *) sIn; UInt8 *key = (UInt8 *) sKey; UInt8 s[256]; UInt8 k[256]; UInt32 i; UInt32 j; UInt8 temp; UInt32 t; UInt32 x; for (i = 0; i < 256; i++) { s[i] = (UInt8) i; } j = 0; for (i = 0; i < 256; i++) { k[i] = key[j++]; j %= iKeyLen; } j = 0; for (i = 0; i < 256; i++) { j = (j + s[i] + k[i]) % 256; temp = s[i]; s[i] = s[j]; s[j] = temp; } i = 0; j = 0; for (x = 0; x < iInLen; x++) { i = (i + 1) % 256; j = (j + s[i]) % 256; temp = s[i]; s[i] = s[j]; s[j] = temp; t = (s[i] + s[j]) % 256; inp[x] ^= s[t]; } } 2008/4/25 Lionscribe <[EMAIL PROTECTED]>: > AESLib > http://www.copera.com/AESLib/index.html > > -- > For information on using the ACCESS Developer Forums, or to unsubscribe, > please see http://www.access-company.com/developers/forums/ > -- Alan Ingleby -- For information on using the ACCESS Developer Forums, or to unsubscribe, please see http://www.access-company.com/developers/forums/