Gus Parker

Greenhorn
+ Follow
since May 10, 2009
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 Gus Parker

Ulf Dittmer wrote:

byte[] textDecrypted2 = desCipher.doFinal(text)


This doesn't make sense to me. "text" is not encrypted - it is the original cleartext, so any attempts to decrypt it would result in garbage.

Aside #1: Any time you're using String.getBytes() instead of String.getBytes(String) the code is dependent on the platform you're running. If this code is supposed to run on different platforms (OS X, Windows, Linux, ...) then that is a bug waiting to happen.

Aside #2: DES is weak and obsolete. Use at least Triple-DES (the algorithm for which is called "DESede" in Java parlance).



Hi, thanks for your reply, you've given me a couple of things to look into there, cheers

With the "text", What I'm trying to do is input the encrypted message that I have already encrypted to the textfile(I've got the first half right).......

I'm really not sure I'm doing the right thing though.

What I've done is encrypted the message, got the secret key, along with the encrypted message from the textfile
and tryed to rebuild the string in another class.....

where I have:


which equals to :

javax.crypto.spec.SecretKeySpec@fffe793d

.........

I have a suspicion that might be were the problem is.....

when i run:



and then print myDesKey....

it shows something like....

com.sun.crypto.provider.DESKey@fffe7f57



So if I have the key, can I just decrypt the encryted message anywhere?
Do you think that might be the problem, the key issue?
Or am I totally on the wrong path?
14 years ago
Hi,

I'm new to encrypting data in JAVA, have spend a few days reading up about it
and trying several methods, the methods I have got to work have pretty weak encryption.

The code below is one I'd really like to get working properly but seem to be having trouble with

Any point in the right direction, or what I am doing wrong would be great help.

Cheers



This code - Works fine.



The trouble is I want to write the encrypted message into a text file, then read it again
from another class.

So I tryed this below, tryed break down the key, then trying to rebuild the key (so I can
use it in another class once I get this right)

As you can see down the bottom, the first "Text Decryted : " Message will only show the
message it originally generate for this instance.

BUT the second one fails when it trys to Decrypt the code I have given it from class, the key
I've used with the 2nd one I have taken from another instance of running the program (the one
were I got the encrypted message to be decryted)




Do you think I'm going about this the right way, am I getting warm with it?

Is there a better way to be doing this?

Basically I want to take a string, encrypt it, save that to a text file, then decrypt it to read it
later on.

Any help would be fantastic,

Cheers, good day to you :-)

14 years ago
Hi,

I'm new to encrypting data in JAVA, have spend a few days reading up about it
and trying several methods, the methods I have got to work have pretty weak encryption.

The code below is one I'd really like to get working properly but seem to be having trouble with

Any point in the right direction, or what I am doing wrong would be great help.

Cheers



This code - Works fine.



The trouble is I want to write the encrypted message into a text file, then read it again
from another class.

So I tryed this below, tryed break down the key, then trying to rebuild the key (so I can
use it in another class once I get this right)

As you can see down the bottom, the first "Text Decryted : " Message will only show the
message it originally generate for this instance.

BUT the second one fails when it trys to Decrypt the code I have given it from class, the key
I've used with the 2nd one I have taken from another instance of running the program (the one
were I got the encrypted message to be decryted)




Do you think I'm going about this the right way, am I getting warm with it?

Is there a better way to be doing this?

Basically I want to take a string, encrypt it, save that to a text file, then decrypt it to read it
later on.

Any help would be fantastic,

Cheers, good day to you :-)

14 years ago
Hi, hope you're well :-)

just having a little problem, I know how to update a textField with Actionlistener once the GUI has loaded using "setText"

So I have 2 JCombobox's........
but what I want to do is update the entire contents of the 2nd JComboBox depends on what is selected in the 1st JComboBox...once the gui has loaded to contain an array of values depending on which

is there a similiar function liek "setText" for JComboBox's....like there is for the TextField and setText....

how would one go about doing this, any point in the right direction would be much appreciated

....

Example scenario.

I have a JCombobox A with Countries.
I want to have the cities for that country in JComboBox B when you select it in ComboBox A.

Thanks :-)
Gus.
14 years ago
Thanks everyone for replies.

After trying a few things, the below code I have works fine.



Thanks
14 years ago
Thanks Henry Your 2 posts there have been helpful, I'll give this all some thought

-Gus
14 years ago

Henry Wong wrote:

dam still cant get it working



Well, there are a few reasons why you would make such a post....

1. you tried something new and it still didn't work.

2. you are frustrated that no-one answered the question to your needs and wants an answer.

And in both of these cases....

Can you help or not?



You stand a better chance of getting a better answer if you provide more details.... Basically, Campbell, is *not* accusing you of "looking for the quick answer". He is asking you for elaboration so he can help you.

Henry



Hi Henry,

Really I want to get this code working without having to scrap it and try something new. I find it an interesting challenge - as someone new to Java and programming - to want to finish something I started to help my education. The reason I posted that was...

3. To try and get some help to my original question - Am I going about this the right way, or should I be heading down a different path?

I'd like to know if there is a better way to go about this, an easier way. I feel like I might be stumbling around with a silly solution to this, when there might be something more worthwhile for this situation that I can go and look at and study, to find out more about it.

Do you think I'm heading down the right path for this?
Am I making a slight error?
Will my 3 loops in one work if I go about it the right way?
Is this good practice in the world of programming?


14 years ago

Campbell Ritchie wrote:

Gus Parker wrote:dam still cant get it working

Tell people what is going wrong. And it's spelt "damn."



If you read my first post, you'd notice a specific question not related to looked for a quick answer. I asked a question that was looking for a serious answer. Am I was heading down the right path with it all? I came here for help, if you can't help in the way I originally asked, move on and stop being a smart ass.......

Sentences don't start with "and". Now we're even on the spelling/punctuality. Can you help or not?

14 years ago
dam still cant get it working
14 years ago

clara irma wrote:Hello,

in your line allstudentObjArray[i3][i2] = new stuAll(sal.next())
isn't it supposed to be allstudentObjArray[i3][i2] = new Student(sal.next()), with Student constructor taking a String parameter.
That depends on what 'stuAll' is in your code..

There are several other things:
For one thing, you put a 'i2++' and 'i3++' inside both of your for-loop. This will make the values incremented twice.

And in your code, for each line found in 'allStu', you run the nested for-loops, taking values from the 'sal' object.
But you never re-assign 'sal' to the next new line, so 'sal' here only has the value of the first line in allStu (which, after all token has been retrieved using .next(), should cause an exception).

You might also wants to review your logic, with the nested for-loops inside the while loop. Because the while loop (when used properly) should already serves as iterator of your lines, so you shouldn't need double loop there, depending on what you are trying to achieve..



Hi Clara, thanks for your reply.

I'm not sure if it's good and going to work or not, but with the i2++ and i3++ , i have those together in seperate loops, but still in the while loop,

so ive got

while loop = each line
first for loop = the go through and increment the first value part of multi array- [this bit][] - ....
second for loop = for each of the first values of the multi array, add each value as it delimits from the line current on in [] [this bit]

i hoping to pull the above off, would be great if i could....

but...

i just cant get this line right

"allstudentObjArray[i3][i2] = new stuAll(sal.next()) "...

but ass you mentioned I think i need to try Student there.

but do you think the Sal bit will work to go through each delimit and add it, im wondering

I'll have to try later.
14 years ago

Jeanne Boyarsky wrote:Does this compile?

new stuAll(sa1.next());

stuAll is a variable name in your code. But having "new" before it, implies that it is a type.



Sorry I dont have a compiler handy for a few hours, thanks i'll try this out tonight, although I'm fairly sure I tryed this (but cant be sure).

I originally had a much longer code to do all of this, but wanted to trim it down a lot, (also makes it easier for other parts of the program as well)....

Do you think I'm going about this the right way, or is there something else that would be easier you could suggest?
14 years ago
Heres my method, explaination and question below




Pretty much what Im trying to do here is, go through each line of the text file with values delimited by :
there are 11 lines, with 13 values in each line all seperated by a ":"

I want to put these into this 2D array and then take them out for use as needed by my program.

Im trying to use two for loops, one for the line to go and then one for the values.

I seem to be doing something wrong, it seems to be happening around the stage when I try to put the delimited value in
one by one.

Am I going about this the right way, or should I be heading down a different path?

Or is there something small I'm just not doing right,

say around this line "allstudentObjArray[i3][i2] = new stuAll(sa1.next());"
14 years ago
Oh yeah and one last thing,
so if i want to print can I use:

System.out.println("Volume is : " + vol.length);

can i also use

System.out.println("Volume is : " + vol[2]);

is that correct?

Just as normal?
14 years ago

Henry Wong wrote:

Is it as simple as an individual value - but just calling it an array - instead of say a string - or is it more complex. Please Help



A string is an object. An array is an object. Passing either around is just passing an object around. What problem have you run into that you see it as different?

Henry



Thanks Henry for clearing that up, I'm still new and that helps me out, Much Appreciated.
14 years ago

Bhagat Singh Rawat wrote:See the changes in BoxVol Class:



aaaah I see, dont have a compiler right now to test, but that makes perfect sense, such a small thing, thank you very much for your reply, much appreciated.
14 years ago