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

  • SEARCH
  • Home
  • 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 8871063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:53:13+00:00 2026-06-14T17:53:13+00:00

I am using the Android javax API to encrypt a string which returns a

  • 0

I am using the Android javax API to encrypt a string which returns a byte array which I again convert into String (purpose is to write to textfile later).

Now using this String, I convert to byte array to decrypt which returns another byte array which I convert again to String.

I could not get this to work. I narrowed down the issue to the string conversion to byte array portion. Because if i use the encrpted byte array to decrypt and then get the String it works.

Not sure what’s the issue. I have used the following for the conversion:

String str;
Byte [] theByteArray = str.getBytes("UTF-8");
String val = new String (theByteArray , "UTF-8");

and 

Byte [] theByteArray = str.getBytes();
String val = new String (theByteArray);

What is the best way to convert from byte array to string and vice versa without losing anything?

  • 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-14T17:53:14+00:00Added an answer on June 14, 2026 at 5:53 pm

    You can use apache library’s Hex class. It provides decode and encode functions.

    String s = "42Gears Mobility Systems";
    byte[] bytes = Hex.decodeHex(s.toCharArray());
    
    String s2 = new String(Hex.encodeHex(bytes));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to encrypt a string using the BouncyCastle API in Android to
Well am using eclipse to make an android app which accesses google calendar API
I have an Android application, which uses javax.crypto to encrypt some text data in
I have a Java handler code which Im using in android to run a
My own project is using Android 2.1 API 7 . To implement action bar,
I am searching for some way of using any Google API or android framework
Possible Duplicate: Sending Email in Android using JavaMail API without using the default/built-in app
I'm using the JavaMail API that's been ported for Android found here but I
I was creating notification using builder class and using android 4.1 version (API level
I have a native shared library compiled using android-ndk one of the C API

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.