- Timestamp:
- 2007-10-07T22:07:25Z (17 years ago)
- Branches:
- master
- Children:
- 2896674
- Parents:
- 2305488
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/arc.c
r2305488 re2869bf 61 61 struct arc_state *st; 62 62 int i, j, tmp; 63 unsigned char S2[256]; 63 64 64 65 st = g_malloc( sizeof( struct arc_state ) ); 65 66 st->i = st->j = 0; 66 for( i = 0; i < 256; i ++ )67 st->S[i] = i;68 69 67 if( kl <= 0 ) 70 68 kl = strlen( (char*) key ); 71 69 70 for( i = 0; i < 256; i ++ ) 71 { 72 st->S[i] = i; 73 S2[i] = key[i%kl]; 74 } 75 72 76 for( i = j = 0; i < 256; i ++ ) 73 77 { 74 j = ( j + st->S[i] + key[i%kl] ) & 0xff;78 j = ( j + st->S[i] + S2[i] ) & 0xff; 75 79 tmp = st->S[i]; 76 80 st->S[i] = st->S[j]; 77 81 st->S[j] = tmp; 78 82 } 83 84 memset( S2, 0, 256 ); 85 i = j = 0; 79 86 80 87 for( i = 0; i < cycles; i ++ ) … … 104 111 st->S[st->i] = st->S[st->j]; 105 112 st->S[st->j] = tmp; 106 107 return st->S[(st->S[st->i] + st->S[st->j]) & 0xff]; 113 tmp = (st->S[st->i] + st->S[st->j]) & 0xff; 114 115 return st->S[tmp]; 108 116 } 109 117
Note: See TracChangeset
for help on using the changeset viewer.