Philip Fry

Greenhorn
+ Follow
since Sep 21, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Philip Fry

I was under the impression that blobs were for files like media files or pictures? Also I am not able to insert to Blob type fields things like: 81-88108101-39-95348102-413-2318-44-95-4029-92-11-53115-124-89-89080-102126888411531
because an exception is being thrown:



And it works with clobs type fields.
Hello,

I need some guidance with handling clob data. I have a derby table:

Hashes and salts are generated like this:

Then records are stored like this:

This bit works fine. At least I am convinced so.
Once I store the digests in a DB I use this method to compare them:

Hash and salt arguments being passed to the compareHashes() are the ones retrieved from a database with:

and also:

Clearly I am doing something wrong with getting data from Clobs. And this:

is the only way I coud come up with to convert the clob back to array, which isn't working like i would like it to. I thought byte[] arrays passed were binary and since clobs are? also binary it would work with out additional conversions.
Do any of you have any ideas/suggestions/libraries which would be able to convert the clobs to what I want?
Just came back to say thanks to Jasper again. That library is great and sorts out the issue.
12 years ago
Wow. Thanks for such a quick reply.

I'll look into what you suggested.
I'd rather avoid converting Strings into bytes[], just haven't been able to find a way yet.
12 years ago
Hello,

I've been trying to write my first app, and I'd like for it to store users passwords. Eventually.I have been am using apache.derby for a database and been able to add users to the table in the said database.
Records consist of: login(string), hash(string), salt(string). Or varchars rather.
I've been using JPassworField for getting password char[] arrays. Then have been converting them to byte[]->to Strings, and inserting them into the table. Like this:



The query: "select * from users;" displays everything as it should so it's all good. Originally I was trying to retrive each hash as byte[] array as follows:

but some exception would be thrown saying getting byte[] from varchar field cannot be done. So i tried changing the field data type to a varchar for bit data, or a blob, as I found in some Oracle's pdf doc these were the data fields types I could retrieve bytes[] array. No luck, whatever. So I moved on to using Strings.

Now, here's what just won't work and I honestly am not able to comprehend. Hashes are generated and stored in a digested forms using:



How I convert Strings to byte[] arrays (which also seams to be working):



Then I compare digests with:



digesta and digestb are instance varaiables btw.

And like I said before, select * query shows all the records as it should, and hashes are composed of some weird characters. But encoding/decoding? seams to be working, and I have checked that by displaying system,outs before and after every step involving storing/retrieving/converting the particular hash in question.

compareHashes method never ever evaluates to true(*). I am sure that there is something not quite right with converting Strings to chars[] and bytes[], I cannot figure out what though.
And yes, I am aware that assigning passwords to Strings is not the brightest idea, as such strings could be dumped and what not. However, since I haven't been able to use chars[] and bytes[], it appeared as a good and easy enough, temporary and optional solution. I was wrong yet again. No surprises there

Hence my question: how do i compare stored digests with generated digests on the go for them to be equal? I know am quite close to solving it, as when i put the above two methods in a separate class along with main method, surprisingly it works(*):



There are neither exceptions or errors and code compiles so am not sure what else to post.
Also, my English is far from awesome, so I hope you guys can understand what I am trying to say here.

Help?
12 years ago