// ice cipher source: http://www.darkside.com.au/ice/index.html
#include "ice.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int main (){
FILE *fp, *fout;
int count = 7730712; // copy from folder/file name size
int count2 = 0;
fp = fopen("filename.dat","rb"); // encrypted filename block (I dump to a file for test.)
fout = fopen("output.dat", "wb"); // the file to write out the decrypted text to file.
uint8_t *ctext = (uint8_t *) malloc(count); // alloc to meet our need.
uint8_t *ptext = (uint8_t *) malloc(count);
if (fp==NULL) {
perror ("Error opening file");
}
else {
// count2 is the real bytes count that program read out, but should be same as "count".
count2 = fread(ctext, 1, count, fp);
printf ("Total number of bytes read: %d\n", count2);
const uint8_t *s = "\x51\xF3\x0F\x11\x04\x24\x6A\x00"; // it's a magic, you know.
ICE_KEY *ik = ice_key_create(0); // init the key
ice_key_set(ik, s); // set the key
long cuts = count2/8;
while (cuts--){
ice_key_decrypt(ik, ctext, ptext); // key, in (encrypted text), out (decrypted text)
ctext +=8;
ptext +=8;
}
ptext -= count2; // reset the pointer back to the begining.
fwrite(ptext, 1, count, fout);
fclose(fout);
fclose(fp);
}