Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char * AES_128_ECB_PKCS5Padding_Decrypt(const char *in, const uint8_t* key)
- {
- size_t inputLength = 0;
- uint8_t *inputDesBase64=b64_decode_ex(in,strlen(in), &inputLength);
- // const size_t inputLength= (strlen(in) / 4) * 3;
- uint8_t *out=malloc(inputLength);
- memset(out,0,inputLength);
- size_t count=inputLength/16;
- if (count<=0)
- {
- count=1;
- }
- size_t i;
- for ( i = 0; i < count; ++i) {
- AES128_ECB_decrypt(inputDesBase64+i*16,key,out+i*16);
- }
- // remove padding
- int index = findPaddingIndex(out, inputLength);
- if(index==NULL)
- {
- return (char*)out;
- }
- if(index < inputLength){// if (index>strlen) will crash.
- memset(out+index, '\0', inputLength-index);
- }
- free(inputDesBase64);
- return (char *) out;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement