Re: Storing byte[] array
Re: Storing byte[] array
- Subject: Re: Storing byte[] array
- From: Mark Morris <email@hidden>
- Date: Sat, 26 Mar 2005 17:13:57 -0600
I think it was as simple as creating a Byte object with the byte, then
calling toString(). Build a String by appending each byte's 2-char
String representation. Do the reverse when reading back from the db in
the accessor.
I know it wasn't hard, but I don't have the code in front of me. And
to me, for small strings (like under 100 or so chars), it made sense to
me to store it as a varchar. But then, that may have just been what
was more comfortable for me. ;-)
Regards,
Mark
On Mar 26, 2005, at 5:01 PM, Drew Thoeni wrote:
The result is an array with 24 bytes, each being a hex. I think I am
also missing something. byte is a primative and, I thought (I'm pretty
new at this) it would not have any methods. How do you go about
converting it to to two chars hex?
BLOB, though, might be simpler.
Drew
On Mar 26, 2005, at 5:54 PM, Mark Morris wrote:
Of course, for larger chunks of data, a BLOB or similar might be a
better choice. ;-)
-- Mark
On Mar 26, 2005, at 4:50 PM, Mark Morris wrote:
When I've run into this problem, I've taken the brute-force, it may
not be the most efficient but it'll work, approach of converting the
byte[] into a hex string, and storing this. It doubles the storage
required (2 chars per byte), so it depends on the data requirements
if it's the right answer for you. But you're pretty much guaranteed
to get back from the db what you stored. The nice thing is you can
implement it in your accessor methods and never worry about it
again. :-)
Regards,
Mark
On Mar 26, 2005, at 4:27 PM, Drew Thoeni wrote:
I've successfully implemented the javax.crypto.spec.PBEKeySpec
(password-based encryption) for encrypting key information in my
database. I can encrypt and decrypt with ease now. But wait! I
can't seem to figure out how to store this marvelously encrypted
info.
The PBEKeySpec pbeCipher.doFinal() generates a byte[] array, each
byte being a hex value. In any attempt I have made in storing this
to the database, WO converts it to a string and gets very
unpredictable results due to the conversion to non-printable
characters.
How is this normally done so it can be store and, importantly,
retrieved in a form that can be converted back?
Regards,
Drew
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden