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FF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
int sceBaseDecoder(unsigned char *decbytes, unsigned char *encbuf, int length) {
char encbytes[4];
int count=0;
unsigned int decword;
if(length==0) return 0;
do {
if(encbuf[2]==0x3d) count--;
if(encbuf[3]==0x3d) count--;
encbytes[0]=tabla[encbuf[0]];
encbytes[1]=tabla[encbuf[1]];
encbytes[2]=tabla[encbuf[2]];
encbytes[3]=tabla[encbuf[3]];
if(encbytes[0]<0 || encbytes[1]<0 || encbytes[2]<0 || encbytes[3]<0) return -1;
decword=encbytes[0]<<18|encbytes[1]<<12|encbytes[2]<<6|encbytes[3];
decbytes[0]=decword>>16;
decbytes[1]=decword>>8;
decbytes[2]=decword;
encbuf+=4;
decbytes+=3;
count+=3;
length-=4;
} while(length>0);
decbytes[0]=0x00;
return count;
}
#define COMPORTAMIENTO_NORMAL
#ifdef COMPORTAMIENTO_NORMAL
unsigned char encstr[]="RWwgYXN1bnRvIGVzIHF1ZSBsYSBmdW5jaW9uIHNjZUJhc2U2NERlY29kZXIgcmV0b3JuYSAoZW4gd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ZSBwZXJtaXRlIGV4ZWN1dGFyIGVsZiBjYXNlcm9zIGVuIFBTUCA6cA==";
#endif
unsigned char buf0[0x1000];
int main() {
printf("codificado: %d\ndecodificado (deberia ser esto, hasta esto -2): %d\nen la actualidad es: %d\n\n",sizeof(encstr)-1, (sizeof(encstr)+1)/4*3, sceBaseDecoder(buf0, encstr, sizeof(encstr)-1));
printf("base64 decodificado: %s\n", buf0);
return 0;
}