Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8227377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:06:41+00:00 2026-06-07T16:06:41+00:00

I am writing a program which does security modules such as encryption, signing, etc…

  • 0

I am writing a program which does security modules such as encryption, signing, etc… I had written library in C which does the above mentioned functionality. Now I am calling this C native functions from java by using jni.

The problem I am facing is I am unable to store the result(signed data or encrypted data)into the parameters passed by java. I want to store the result in parameters which I receive. please help me. Thanks alot in advance.

The following are the API that I use in java to call native functions

sign("sign",byte[] file,int filelen,byte[] output,int outputlen)

In native C call I will perform the sign on “file” which is a buffer consists of input file contents and I want to store it to the output. How can I do it can anyone help me I did not found any related information.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:06:43+00:00Added an answer on June 7, 2026 at 4:06 pm

    The following code allows your native code to directly access the contents of both primitive byte array inputs.

    JNIEXPORT void JNICALL Java_*mypackage*_sign(JNIEnv* env, jbytearray input, jint ilen, jbytearray output, jint olen) {
      char* pinput = (*env)->GetByteArrayElements(env, input, NULL);
      char* poutput = (*env)->GetByteArrayElements(env, output, NULL);
    
      sign(pinput, ilen, poutput, olen);
    
      (*env)->ReleaseByteArrayElements(env, input, pinput, 0);
      (*env)->ReleaseByteArrayElements(env, output, poutput, 0);
    }
    

    Depending on your performance considerations (i.e. if you want to ensure that you avoid copying the array data, or avoid concurrent access to the byte arrays), here is an example of using GetPrimitiveArrayCritical.

    An NIO/direct buffer is only recommended if you need the buffer to be shared between native and Java code for longer than the duration of a single function call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a program, which takes two words as command line arguments, does something
I am interested in writing a Java program which does the following. Attach to
I am writing program that does alot of table lookups. As such, I was
I am writing a program which needs to be run in Android 2.0. I
I am writing a program which needs to access data in a web server.
I m writing a program which involves converting java.util.Date to java.sql.Date... I've done it
I am writing a program which collects lots of individual pieces of data from
I'm writing a program which has both an ASP.NET configuration system and a Silverlight
I am writing a program which if I compile on a Suse 10 32-bit
I'm writing a program which will use scan conversion on triangles to fill in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.