Salut !
Voilà je dois utiliser le code suivant dans un serveur en VB6 pour décrypter/encrypter :
--------------------------
struct RC4STATE {
unsigned char l1, l2, s[256];
};
//
// Used for v3.3+ clients to initialize RC4
//
const unsigned char rc4_init_v33[16] = {
0x057, 0x04F, 0x049, 0x036, 0x0A, 0x0FE, 0x022, 0x007,
0x0DF, 0x0B3, 0x036, 0x099, 0x097, 0x02B, 0x05A, 0x0E1
};
//
// Used for v3.3+ worlds to initialize RC4
//
const unsigned char rc4_init_world_v33[16] = {
0x058, 0x059, 0x0A1, 0x0F5, 0x06F, 0x0B8, 0x075, 0x0C4,
0x0E0, 0x04E, 0x042, 0x080, 0x020, 0x00C, 0x09E, 0x088
};
//
// Initialize p using init which is init_len bytes long
//
void rc4_init(struct RC4STATE *p, const unsigned char *init, int init_len)
{
unsigned char tmp = 0;
int i, j = 0;
p->l1 = 0;
p->l2 = 0;
for (i = 0; i < 256; i++) {
p->s[i] = i;
}
for (i = 0; i < 256; i++) {
unsigned char tmp2 = p->s[i];
tmp = tmp2 + init[j] + tmp;
p->s[i] = p->s[tmp];
p->s[tmp] = tmp2;
if (++j >= init_len) {
j = 0;
}
}
}
//
// Get next byte in keystream from p
//
unsigned char rc4_get_key(struct RC4STATE *p)
{
unsigned char tmp;
p->l1++;
p->l2 += p->s[p->l1];
tmp = p->s[p->l2];
p->s[p->l2] = p->s[p->l1];
p->s[p->l1] = tmp;
return p->s[(p->s[p->l1] + p->s[p->l2]) & 0x0ff];
}
//
// Skip keys in the keystream from p
//
void rc4_skip_keys(struct RC4STATE *p, unsigned short skip)
{
while (skip-- > 0) {
rc4_get_key(p);
}
}--------------------------
Si quelqu'un pouvait me le convertir en VB ou le mettre en DLL utilisable sous vB, je le remercierai infiniment !
Si vous voulez plus d'informations sur la méthode utilisée pour crypter, demandez-moi. Le cryptage est celui utilisé par ActiveWorlds :-)
Je vous remercierai en vous offrant une bannière de 1 mois (voir plus) sur mon forum de bientôt 3000 utilisateurs.