I have this simple question but i dont know which method to convert it..
the case is like this:
i have encrypted a string in byte[] form.
and since it is a string already, but in the end i still need to decrypted it back to original string. for example: -
String str = "Peter is smart";
-
-
// encrypt it
-
byte[] data = enc.encryptString(str);
-
-
String test_str = data.toString();
-
System.out.println(test_str); // this value is : [B@356f
-
-
-
String str2 = getTest_Str(); // this String field is a must and value is [B@356f
-
-
// here i want to make the string into byte[]
-
byte[] bb = str2.someMethod();
-
-
System.out.println(bb); // i want this bb value to be exactly the same as test_str above, is [B@356f.
-
-
// here i can do decryption which take byte[] as parameter.
-
System.out.println(enc.decryptString( bb )); // this should print "Peter is smart"
-
how to make the string to byte[] without changing the value?
any idea of what i'm talking about ?
any idea ?
thanks in advance.
Nick
9 5706
One of the constructors of the String class takes a byte[] array as an argument.
kind regards,
Jos
One of the constructors of the String class takes a byte[] array as an argument.
kind regards,
Jos
i know.
maybe the way i explain is confusing but the string is [@B43f.
decryptString(byte[] b) takes byte[] as argument.
So i have to make "[@B43f" to byte[] first, and then pass to decryptString(xx) method.
but i dont know how to make a string to byte[] without changing the value(in this case is [@B43f ) so that the string is [@B43f and the byte array is also [@B43f.
String(byte[]) returns string, not return byte[], so it not help in this case.
any idea?
somehow look like this: -
-
String str = "[@B43f";
-
-
byte[] b = str.clone();
-
-
System.out.println("b = " + b); // if this value is [@B43f, then means this is what i want.
-
-
but i'm not sure whether this is the way of doing it cos i dont have Eclipse or jdk in my pc here.
somehow look like this: -
-
String str = "[@B43f";
-
-
byte[] b = str.clone();
-
-
System.out.println("b = " + b); // if this value is [@B43f, then means this is what i want.
-
-
but i'm not sure whether this is the way of doing it cos i dont have Eclipse or jdk in my pc here.
Wait until you have access to a compiler, then. Us telling you yes or no isn't going to help you learn.
Wait until you have access to a compiler, then. Us telling you yes or no isn't going to help you learn.
it doesn't work in j2me application.
i've tried.
any method to do that?
it doesn't work in j2me application.
Why doesn't it work? Analyzing why it failed may help you find a solution.
i found code from website eventually that helps me with that.
thanks for your time tho.
NickyEng
Why doesn't it work? Analyzing why it failed may help you find a solution.
you're talking like talk pointless.
if everyone could analyze the question, then we don't need to come here and post question tho.
anyway, thanks.
you're talking like talk pointless.
if everyone could analyze the question, then we don't need to come here and post question tho.
anyway, thanks.
I was replying to your post where you said
it doesn't work in j2me application.
It's important to learn how to express problems in better detail. You don't just go to your doctor and only say "I am unwell." Perhaps this article should be in a sticky post at the top of the forum: How to ask questions the smart way. Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nathan |
last post by:
Is there a way to convert a string to a CipherMessage? I am calling a
function that decrypts a CipherMessage and returns the value. The only
problem is when I want to use an encrypted value stored...
|
by: Swarup |
last post by:
I am reading a file (txt, xml, gif, ico, bmp etc) byte by byte and filling
it into a byte arry. Now i have to convert it into a string to store it in
the database.
I use...
|
by: Ricardo Quintanilla |
last post by:
i have a code that sends data to a socket listening over as400 platform,
the socket responds to me as a "byte array".
then i need to convert the "byte array" into a string.
the problem is that...
|
by: dale zhang |
last post by:
Hi,
I am trying to save and read an image from MS Access DB based on the
following article:
http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp
Right now, I saved images without any...
|
by: Charles Law |
last post by:
I thought this was going to be straight forward, given the wealth of
conversion functions in .NET, but it is proving more convoluted than
imagined.
Given the following
<code>
Dim ba(1) As...
|
by: moondaddy |
last post by:
I'm writing an app in vb.net 1.1 and need to convert a byte array into a
string, and then from a string back to a byte array.
for example
Private mByte() as New Byte(4){11,22,33,44}
Now how...
|
by: Bob Altman |
last post by:
Hi all,
I'm looking for the fastest way to convert an array of bytes to String. I
also need to convert a String back to its original Byte() representation.
Convert.ToBase64String and...
|
by: Peter |
last post by:
Trying to convert string to byte array.
the following code returns byte array of {107, 62, 194, 139, 64}
how can I convert this string to a byte array of {107, 62, 139, 65}
...
|
by: est |
last post by:
From python manual
str( )
Return a string containing a nicely printable representation of an
object. For strings, this returns the string itself. The difference
with repr(object) is that...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |