linux ascii to utf-16 (then sha1 and base64) encode
We have a communication protocol that requires us to Base64 Encoded a SHA1 hash of a UTF-16 encoded password. We have been given Java, javascript, and visual basic examples however we are running under Linux (redhat) the provided test string:TESTED@8691 the final output:rBbBKqbJodT5awZal/CSCYF/sFo= I have tried
iconv_t conv = iconv_open("UTF-16LE","ASCII"); // open succeedschar *from_string=strdup("TESTED@8691");size_t from_length=strlen(from_string);size_t to_length=from_length*3;size_t original_to_length=to_length;char *to_string=(char*)calloc(1,to_length);int convert_return=iconv(conv,&from_string,&from_length,&to_string,&to_length);// convert_return is 0 indicating success, to_length is 22, from_length is 0
you were using char* for input what cannot work in my opinion.
Sara