Translit xor crypting c++ to php -
i want translit xor crypting c++ php. use function crypting. want decrypt file php.
wchar_t* encryptdecrypt(const wchar_t* toencrypt, int length, wchar_t* ebkey) { const wchar_t* key = ebkey; wchar_t* output = new wchar_t[length]; (int = 0; < length; i++) { output[i] = toencrypt[i] ^ key[i % wcslen(key)]; } return output; }
i read xls file binary , crypt encryptdecrypt
void encryptandsave(char *src,ansistring key) { wchar_t *content; wchar_t buffer[255]; wchar_t *result; long size; long fsize; file *f=null; f=fopen(src,"rb+"); fseek(f, 0, seek_end); size = ftell(f); fseek(f,0, seek_set); content = (wchar_t *) malloc(size * sizeof (wchar_t)); fread(content, size, 1, f); fclose(f); content=encryptdecrypt(content,size,strtowchar_t(key)); f=fopen(src,"wb+"); fwrite(content, size, 1, f); fclose(f); }
i use function convertion key in wchar_t
wchar_t* strtowchar_t(ansistring value) { int isize = value.widecharbufsize(); wchar_t *tmp = new wchar_t[isize]; value.widechar(tmp,isize); return tmp; }
this code in php decrypting
function encryptdecrypt($toencrypt,$key) { $output=array(); ( $i = 0; $i < strlen($toencrypt); $i++ ) { $output[$i]= $toencrypt[$i] ^ $key{$i % strlen($key)}; } return $output; }
but not rightly decrypting.when crypt , decrypt c++ word, result must "qwerty" "ﻎcdt@gh", in php not work c++. when decrypt "ﻎcdt@gh" in php "яМp1v3e2s1u3y2", must "qwerty". please resolve problem.
Comments
Post a Comment