Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enc_string RJContextEncode(JNIEnv* je, RJContext& context, const std::string& input) {
- std::string in_v = input;
- unsigned int sum_v = HashSum((const signed char*)in_v.data(), in_v.size());
- out_oscar_buffer bs;
- bs << DWORD_LE(sum_v);
- in_v.append(bs.as_string());
- enc_string r;
- unsigned char* b = (unsigned char*) alloca(in_v.size() + 16);
- memcpy(b, in_v.data(), in_v.size());
- int len = in_v.size();
- if (len % 16) {
- len += 16 - (len % 16);
- }
- if (len % 16) {
- logd(TAG, "RJContextEncode fail: if(len%16)");
- return enc_string(); //throw ("if(len%16)");
- } else if (input.size() == 0) {
- logd(TAG, "RJContextEncode fail: buffer length == 0");
- return enc_string();
- } else {
- unsigned char* output = (unsigned char*) alloca(len);
- block_encrypt(&(context.rjctx_out), b, len,output, context.rjIV_out);
- r.buf = std::string((char*)output, len);
- r.original_size = input.size();
- log(je, TAG, "RJContextEncode r.buf.size()=%d", r.buf.size());
- return r;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement