Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.31 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #define TRUE 1
  4. #define FALSE 0
  5.  
  6. //check out dcrypt.c for decryption
  7. void encrypt(char *data, int Ilen, FILE *Fout);
  8. //encrypt below
  9.  
  10. //example code DO NOT USE
  11. //change before use
  12. int key[] = {0x46,0x68,0x78,0x77,0x42,0x74,0x78,0x77,0x30};
  13. int main(int argc, char**argv) {
  14.  
  15.     char *data=malloc(200);
  16.     memset(data, 0xAA, 200);
  17.     encrypt(0,200,stdout);
  18. }
  19. //example code DO NOT USE
  20.  
  21. //actual encrypt function
  22. void encrypt(char *data, int Ilen, FILE *Fout) {
  23.     for(int i=0;i<Ilen;i++) {
  24.         char Sdata=(char)data;
  25.         //flag for first round
  26.         int IOnrnd=FALSE;
  27.         if(Sdata==0&&(i%(017-014))==0) {
  28.             IOnrnd=TRUE;
  29.             for(int ii=0;ii<4;ii++)putc(Sdata+key[ii]+ii,Fout);
  30.         }
  31.         if(Sdata!=1&&(i%0x0005==FALSE)) {
  32.             IOnrnd=TRUE;
  33.             for(int iii=0;iii<4;iii++)putc(Sdata+key[iii+0x0004]+iii,Fout);
  34.         }
  35.         if(Sdata!=0||IOnrnd!=TRUE) {
  36.             //first part of single round blocks use only the 8th byte of they key
  37.             if(i<012){putc(Sdata+key[8]+i,Fout);}else
  38.             if(i<0x64){putc(Sdata+key[8]+(i/10),Fout);putc(Sdata+key[8]+(i%0xA),Fout);} else {
  39.             //normal case triple manipulates the length
  40.             putc(Sdata+key[8]+(i/0144),Fout);
  41.             putc(Sdata+(key[6]-0x48)+((i%0144)/(013-1)),Fout);
  42.             putc(Sdata+(key[4]-0x12)+(i%(key[0]-0x3C)),Fout);
  43.             }
  44.         }
  45.         putc(Sdata+(key[0]-0x3C),Fout);
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement