In my code i pass a string and then hash it using HMAC SHA1 algo and then
try to return it to Java. But it is not returning. It crashes or stop as VM
aborts.

The code that aborts is as follows:

return env->NewStringUTF((const char*)digest);
On this statement VM Aborts.

where digest is and unsigned char which has a hashed characters. I logged
digest variable and it showed some ascii values. Probably after hashing it
mush have got few characters like that.

My code is as follows:
<code>
    typedef unsigned char BYTE ;
    unsigned char *test = (unsigned char *)"Hi There" ;
    BYTE Key[20] ;
    BYTE digest[20] ;
    jstring Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
jobject thiz )
    {
       memset(Key, 0x0b, 20) ;

            ////////Next 2 lines are for Hashing the given text
           CHMAC_SHA1 HMAC_SHA1 ;
           HMAC_SHA1.HMAC_SHA1(test, strlen((const char *)test), Key,
sizeof(Key), digest) ;
            ////////
       __android_log_write(ANDROID_LOG_ERROR,"Hello-Sample",(const char
*)digest);
       jstring temp = env->NewStringUTF((const char*)digest);
        return temp;
    }
</code>
While executing    env->NewStringUTF((const char*)digest);  VM aborts


Can someone please tell me how can i rectify it.


Regards

Vinay Julme
**************

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to