Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!

Reuben Cleetus

Ranch Hand
+ Follow
since Jul 13, 2001
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 Reuben Cleetus

Ankur,

You're playing with this poor chap, aren't you?! He asks for how to read and write a word file, and you show him how to read a file and print it to console!

Cheers,
Reuben.
14 years ago
Hi All,

I'm building a Java-based decryptor that's meant to pair with a .NET-based encryption module that uses AES Encryption.

I have the basic setup of my Java Encryptor working, but need to find a way to derive the key in the same manner that the .NET equivalent is doing:

Basically, I need to find an equivalent for adding salt, and performing this pseudo-random key generation, exactly as it's being done in .NET, so that a corresponding Java App could decrypt what this .NET app is encrypting.

Any help greatly appreciated.

// <C# Code>
PasswordDeriveBytes password = new PasswordDeriveBytes( m_sPasswordPhrase, SaltValueBytes, m_sHashAlgorithm, m_iIterations );
// </C# Code>

Here's the basic java code that I'm using:

// <Java Code>
import java.io.*;
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;

public class Bouncer {
private final String myKey = "@1B2c3D4e5F6g7H8";//"krc^agwsgmp^&qs*"; //This is the key used for Encrypting and Decrypting
private Cipher cipher = null;
private KeyGenerator kgen =null;
SecretKeySpec skeySpec = null;

/** Creates a new instance of Bouncer */
public Bouncer() {
initialize();
}

private void initialize(){
try{
//kgen = KeyGenerator.getInstance("AES");
//kgen.init(128); // 192 and 256 bits may not be available
skeySpec = new SecretKeySpec(this.myKey.getBytes(), "AES");

// Instantiate the cipher
cipher = Cipher.getInstance("AES");
}
catch(Exception e){
System.out.println("Error: AES Libraries not found. Details:");
System.out.println(e.toString());
}
}

public byte[] encryptString(String clearText){
byte[] encrypted=null;

byte[] clearTextBytes = clearText.getBytes();

try{
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
encrypted = cipher.doFinal(clearTextBytes);

}
catch(Exception e){
System.out.println("Error occurred while performing encryption. Details:");
System.out.println(e);
}
return encrypted;
}
}

// </Java Code>

Regards,
Reuben.
14 years ago
Hello,
I was wondering if anyone could point me to resources for compiling a case for moving to an Object Oriented Database. I'm searching for business cases, any pros and cons, comparisons to Relational Databases, and other helpful information.
Thanks,
Reuben Cleetus.
16 years ago
Hello All,
A friend of mine asked for some code to find the number of days between two dates. After exploring around a bit, I found that it's actually quite an intricate problem.. what, with leap years, months with irregular number of days, etc.. and there isn't a convenient method of the Date object for the purpose.
Am I wrong in this conclusion, or does Java have a method to give one the days between two dates?
As a sidebar, I did find a library from Object-Refinery which did the trick however (http://www.object-refinery.com/jcommon/index.html).
Regards,
16 years ago
Hello,
Does anyone know when the long promised Eclipse RAD GUI tool for Java arrive? I see that a project called "GEF" is still in its very infancy, and a RAD Java tool seems far away. Does anyone know of a timetable for a tool such as this for Eclipse?
Regards,
Reuben.
Excellent answer(s) Anthony!
16 years ago
Very interesting. Thanks for the link! I'd love to take a look at this 'nice' programming language. What's really intriguing is that it promises to compile to Java Bytecode, which can be run with any 1.2 or later JVM.
Cool.. Or should I say, Nice.
Reuben.
16 years ago
A protected variable or method is visible to all classes in the SAME package.
Regards,
Reuben.
17 years ago
I would still do so for long processes, which can be done asynchronously. Things such as long calculations, data insertions that take a long time, etc., can be done in another object, running in its own thread.
However, such instances are probably not very common, since most data that is saved needs to be done transactionally, where certain actions are taken when it fails, including flagging the user. The problem with doing this asynchronously, is that the saving will be done in another object and thread, so there would be no way of flagging a failure to the user when the page is returned to the user.
Regards,
Reuben.
17 years ago
Thomas, that's exactly right! Pass By Reference is a violation of the rules of good OO Programming.
What makes this "feature" of permitting ByVal and ByRef parameters possible in C# even more frustrating and confusing, is that any method can have a mix of ByVal and ByRef parameters.
Try sifting through the various layers of an application to find a bug, only to find out that a mix of bloody ByVal and ByRefs have been sprinkled all over the place!
I like the simple elegance of Java, and there isn't anything I've seen that comes close.
Regards,
Reuben.
17 years ago
Hello John,
Thanks for your reply -- I actually ended up buying your book! It was highly recommended by friends, and got great reviews on Amazon and other sites.
I think J2ME may become the primier tool of Java programmers in the next few years, as devices exceed PCs in numbers. I think this is already true in Asia and perhaps in Europe as well.
I've already begun making my way through the chapters, and find it a very readable book. I hope somewhere soon it talks about getting MobileSet 2 installed with JBuilder 6 -- I've had trouble getting it working.
Thank You,
Reuben Cleetus.
17 years ago
Hello,
I just installed JBuilder Personal 6, and wanted to install Mobilset Set 2. JB installed just fine, but when installing Mobile Set 2, I get the following error:
---
Can't launch executable.
Could not load jvm.dll
Try re-installing the Java VM or change the Java VM used by the application.
---
I am running Windows 2K Pro, and have JDK 1.4 installed.
Has anyone else faced the same problem? What do I do to fix it? I have tried re-installing JDK 1.4 again, but it doesn't solve the problem.
Thanks for your help,
Reuben.
17 years ago
Hello All,
I am new to J2ME, but after buying my new Motoroka i90c phone (Nextel Service), I am very interested in learning J2ME, and specifically, the MIDP profile.
Does anyone have any books they would recommend for someone with several years of Java experience, keeping in mind that I have never before delved into J2ME (and consequently know very little about it)?
One book I did find was called Core J2ME Technology and MIDP. I almost bought it, but then remembered that my good friends at the Ranch may have a better recommendation!
Thank You,
Reuben Cleetus.
17 years ago
Hello,
This JavaONE, Sun was supposed to take the wraps off JavaServer Faces, a set of GUI widgets for web applications (such as treeviews, tabs, etc.), that allow programmatic access to events and data. However, I haven't really heard much about it, and I wonder just how far along the project actually is.
Anyone who has used ASP.NET's GUI widgets (Server Side Controls), knows well just what a fantastic idea they are. I can't wait for Java to offer the same.
Regards,
Reuben Cleetus.
17 years ago
I'm running Netbeans 3.3.1 on JDK 1.4 without any problems at all. JDK 1.4 supports the mouse wheel intrisically, so there's nothing to do to get the wheel to work with any Java App.
However, if you're using JDK 1.3 (or earlier), and want Mouse Wheel support in Netbeans, there's an open source project that's got a plug-in that will give you mouse wheel support in Netbeans. The URL is: http://nbmousewheel.sourceforge.net/
Regards,
Reuben Cleetus.