>>the encryption is random, it's not always the

>>same text that is resulting from the encryption.

This is true if you use a different key which you are doing as you are generating the key by a random number the encryption will always be different. As the underlined cipher will use the blocks of the key material and do operations on the data and produce the cipher text.

>> How can I change that.

if you use a fixed key (constant symmetric key)you can change that

>>what is a key

to be in simple its the lock and key mechanism as you have the key and you can lock and use same key to unlock. same is the case with cipher class for eg if your cipher class is instantiated for DES in CBC mode the key size would be for e.g. 64 bytes the data will be broken into the chunks of 64 bytes and various reversible operations will be carried out with the data and the key to produce un intelligible data called cipher text.

and since it is reversible same steps are done in reverse order to get the original text back from the cipher text with the help of a key.

>>how do I specify my own key or password so that >>it only decrypts if I use this password?

you can use PBE password based encryption to generate the key which has 3 parameters

1) salt (random byte[8] )

2) iteration count any number

3) password.

if these parameters are constant one can gnerate the key which is constant and hence the cipher text using the cipher class.

>>how can I write the encrypted data to a file?

suerly you can get the cipher data in a byte[] by calling Cipher.doFinal(originaldata[]);

and you can write this data to the fila by opening file out put stream.

what is RSA algorithm, and how is it different from DES, which leads me to another point.

>>RSA algorithm is used for asymmetric key encryption while DES is used for symmetric key encryption.

>>What are Symmetric and Asymmetric Algorithms?

Symmetric key is used whith the Symmetric key algorithm e.g. DES where same key is used for encryption and decryption.

while asymmetric key involves two key pairs which are complementary to each other one is called private key and the other the public key.

public key is known to all but the private key as the name suggests is private to a user. if one encrypts the data with public key only private key can decrypt the data and vice versa.

for e.g.

sender A encrypts data for reciver B using B's public Key

then only B can open the data that too with his Private key.

you should be very clear with the mechanism and note the difference between symmetric key and the asymmeric keys.

I hope this satisfies your queries