Related to JCE

Hi,How do I get to make the following stmt. working.....System.out.println("cipher : " + Utils.toHex(ciphertext));it says "Utils" not foundHow do i make it work ?Any help will be appreciated.Thank you
[249 byte] By [evolushunza] at [2007-10-2 6:14:03]
# 1
> it says "Utils" not found. How do i make it work ?> Any help will be appreciated.First, learn Java. Then, move on to more advanced aspects of Java (like JCE).
ghstarka at 2007-7-16 13:15:33 > top of Java-index,Security,Cryptography...
# 2

I think i made a request, Mr.whatever you are

if you dont know please dont answer

if you can get the following code wrk......i will see wht level of BASIC JAVA you know

*************************************************************

import java.security.Key;

import javax.crypto.Cipher;

import javax.crypto.SecretKeyFactory;

import javax.crypto.spec.IvParameterSpec;

import javax.crypto.spec.PBEKeySpec;

import javax.crypto.spec.SecretKeySpec;

import javax.crypto.spec.PBEParameterSpec;

import javax.crypto.spec.SecretKeySpec;

/**

* Example of using Password-based encryption

*/

public class PBEs

{

public static void main(

String[]args)

throws Exception

{

PBEKeySpec pbeKeySpec;

PBEParameterSpec pbeParamSpec;

SecretKeyFactory keyFac;

// Salt

byte[] salt = { (byte)0xc7, (byte)0x73, (byte)0x21,

(byte)0x8c, (byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99 };

// Iteration count

int count = 2048;

// Create PBE parameter set

pbeParamSpec = new PBEParameterSpec(salt, count);

//Initialization of the password

char[] password = "newpassword".toCharArray();

//Create parameter for key generation

pbeKeySpec = new PBEKeySpec(password);

// Create instance of SecretKeyFactory for password-based encryption

// using DES and MD5

keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");

// Generate a key

Key pbeKey = keyFac.generateSecret(pbeKeySpec);

// Create PBE Cipher

Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");

// Initialize PBE Cipher with key and parameters

pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);

// Our plaintext

byte[] cleartext = "This is another example".getBytes();

// Encrypt the plaintext

byte[] ciphertext = pbeCipher.doFinal(cleartext);

System.out.println("cipher : " + Utils.toHex(ciphertext));

}

}

*****************************************************

evolushunza at 2007-7-16 13:15:33 > top of Java-index,Security,Cryptography...
# 3

As has been pointed out, you need to start by learning Java. If you knew any Java then you would know that you need the class Utils which you have not posted. You need to get the person who gave you the code (you did not write it) to also give you the code for the utility class OR, since it is obvious what the method Utils.toHex() must do, you must find an alternative.

I would offer you an alternative but your attitude stinks.

sabre150a at 2007-7-16 13:15:33 > top of Java-index,Security,Cryptography...