Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Heidarian
Beginner
79 Views

ARCFour Encryption/Decryption Problem

Jump to solution

Dear friends

I wrote this simple code to test the ARCFour algorithm,but when I run my program the decrypted cipher-text is not the same as the original plain-text...could anyone tell me what is wrong with my code??

int ctxSize;
Ipp8u ctext[8];
Ipp8u pDst[8];
Ipp8u key[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
Ipp8u pSrc[] ={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

ippsARCFourGetSize(&ctxSize);
IppsARCFourState* pCtx = (IppsARCFourState*)( new Ipp8u [ctxSize] );
ippsARCFourInit(key,sizeof(key),pCtx);
ippsARCFourEncrypt(pSrc,ctext,sizeof(pSrc),pCtx);
ippsARCFourDecrypt(ctext, pDst, sizeof(ctext), pCtx);

when I debug this code pDst is not the same as PSrc!!!

Thanks in advance
0 Kudos
1 Solution
achrzesz2
New Contributor I
79 Views
Hello Heidarian

I think You should do:

ippsARCFourReset(pCtx);

before decrypting.

Andrzej Ch

View solution in original post

2 Replies
achrzesz2
New Contributor I
80 Views
Hello Heidarian

I think You should do:

ippsARCFourReset(pCtx);

before decrypting.

Andrzej Ch

View solution in original post

Heidarian
Beginner
79 Views
Quoting - achrzesz2
Hello Heidarian

I think You should do:

ippsARCFourReset(pCtx);

before decrypting.

Andrzej Ch

Hello achrzesz2

Thanx very much for your help, I have added ippsARCFourReset(pCtx) before decrption function and decrypted ctext become the same as the original ptext.

again many tanks to you dear.
Reply