• 0

help with DES and AES


Question

hi I have posted something like this before but I am still tackling the problem....

I am trying to encrypt bytes and then add a second encryption then remove the first without removing the second.... I have my reasons for this I need help with this not an alternative....

the encryption can be alternative so DES + DES or AES + DES or AES + AES or anything thing else but it has to be like this ... here is my code so far .... I have got the encryption layers on ... its just getting them off im struggling with (one page test code)....im getting (given final block is not correctly padded)


import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;

public class ObjectCrypter {

public static void main(String[] argv) {

try {

String str = "moo";

byte[] byted = str.getBytes();

Cipher desCipher;
Cipher enCipher;

KeyGenerator keygenerator = KeyGenerator.getInstance("DES");
SecretKey myDesKey = keygenerator.generateKey();

desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");

desCipher.init(Cipher.ENCRYPT_MODE, myDesKey);
byte[] textEd = desCipher.doFinal(byted);

System.out.println("DES?" + new String(textEd));



byte[] byt = textEd;

KeyGenerator keygenerat = KeyGenerator.getInstance("AES");
SecretKey myD = keygenerat.generateKey();

enCipher = Cipher.getInstance("AES/ECB/PKCS5Padding");

enCipher.init(Cipher.ENCRYPT_MODE, myD);
byte[] tex = enCipher.doFinal(byt);

System.out.println("AES?" + new String(tex));

desCipher.init(Cipher.DECRYPT_MODE, myDesKey);
byte[] textDecrypted = desCipher.doFinal(tex);

System.out.println("it work?" + new String(textDecrypted));





}catch(NoSuchAlgorithmException e){
e.printStackTrace();
}catch(NoSuchPaddingException e){
e.printStackTrace();
}catch(InvalidKeyException e){
e.printStackTrace();
}catch(IllegalBlockSizeException e){
e.printStackTrace();
}catch(BadPaddingException e){
e.printStackTrace();
}
}

}
[/CODE]

if you can help it would be great :)

Link to comment
https://www.neowin.net/forum/topic/1120844-help-with-des-and-aes/
Share on other sites

Recommended Posts

  • 0

I'm not sure how this could work, by encrypting it with AES you can't then decrypt it with DES, as it's not in the format the DES algorithm is capable of decrypting.

It's like doing ROT13 then Base64 encoding it, then doing ROT13 again without decoding from Base64, it won't give the intended results.

  • 0

So it looks like you encrypted with DES followed by AES. Shouldn't you decrypt with AES followed by DES?

I'm not sure how this could work, by encrypting it with AES you can't then decrypt it with DES, as it's not in the format the DES algorithm is capable of decrypting.

It's like doing ROT13 then Base64 encoding it, then doing ROT13 again without decoding from Base64, it won't give the intended results.

even when I encrypt with DES both times i still get the same result ...the thing is im trying to set up a safe way to send information where neither party has the others keys so encryptions needs to be removed in the same order they were added .... so if i encrypt the string "moo" ... with a passkey such as "hello" then encrypt the new string with the passkey "goodbye" I then need to remove the encryption "hello" after which i then remove the passkey goodbye .... :p get it?

  • 0
even when I encrypt with DES both times i still get the same result ...the thing is im trying to set up a safe way to send information where neither party has the others keys so encryptions needs to be removed in the same order they were added .... so if i encrypt the string "moo" ... with a passkey such as "hello" then encrypt the new string with the passkey "goodbye" I then need to remove the encryption "hello" after which i then remove the passkey goodbye .... :p get it?

That's completely illogical and will never work. You always have to decrypt in the opposite order of encryption.

  • 0

That's completely illogical and will never work. You always have to decrypt in the opposite order of encryption.

well then maybe you can help me..... I need to create a p2p chat system with encryption.... BUT the encryption key obviously cant be in the source code or sent over the internet in plain text ..... any helps ?

  • 0

well then maybe you can help me..... I need to create a p2p chat system with encryption.... BUT the encryption key obviously cant be in the source code or sent over the internet in plain text ..... any helps ?

Use asymmetric encryption. A popular asymmetric encryption protocol is SSH. The JsCH library seems like a popular Java implementation of SSH.
  • 0

Dude what!

This and your other thread added together... Either you are NOT meant to be a programmer or you've currently got no clue how to be a programmer.

Write down your ideas and think if they're possible or not and try to plot how they would work.

Other thread: I want to make my program impossible for others to decode -> to run on a PC, it needs to be readable by a PC -> by being readable by a PC that also means people can 'read' it -> if I obscure the code will it help? And what downsides will doing that have, will it create bugs or slow down the running of my program and how much, and what will it cost to implement?

This thread: I want to make a secure chat program -> what encrytion will I use? -> What encryption types will I use? -> I do not want to use the same key to encrypt is so I will use asymmetrical encryption.

Etc. otherwise you will unfortunately keep making junk and be a pretty awful programmer.

EDIT: also reguarding SSH, it's a protocol not an encryption standard :p SSH can use various but you'd probably want to look up PGP, RSA etc.

  • 0

... that's why I said it's a protocol. Btw I don't think your ridiculing of the OP is a productive way of helping him.

I'm not ridiculing him, if you walk into your job as project manager of something with no plan, not only will your project never exist, you'll be fired.

Programming is no different.

If you just think 'yeh I`ll do this but no idea how or if its even possible' then you will never do that.

  • 0

Dude what!

This and your other thread added together... Either you are NOT meant to be a programmer or you've currently got no clue how to be a programmer.

Write down your ideas and think if they're possible or not and try to plot how they would work.

Other thread: I want to make my program impossible for others to decode -> to run on a PC, it needs to be readable by a PC -> by being readable by a PC that also means people can 'read' it -> if I obscure the code will it help? And what downsides will doing that have, will it create bugs or slow down the running of my program and how much, and what will it cost to implement?

This thread: I want to make a secure chat program -> what encrytion will I use? -> What encryption types will I use? -> I do not want to use the same key to encrypt is so I will use asymmetrical encryption.

Etc. otherwise you will unfortunately keep making junk and be a pretty awful programmer.

EDIT: also reguarding SSH, it's a protocol not an encryption standard :p SSH can use various but you'd probably want to look up PGP, RSA etc.

actually .... I get As in all my programming exams and assignments..... there are just some things I have yet to do .... I have moved on to network programming .... please do not underestimate me.... I dislike you **** OFF

I'm not ridiculing him, if you walk into your job as project manager of something with no plan, not only will your project never exist, you'll be fired.

Programming is no different.

If you just think 'yeh I`ll do this but no idea how or if its even possible' then you will never do that.

you are you are taking the ****... im asking questions to help me understand .... I find programming easy but guess what I have to learn it in specific ways I understand .... not everyone speaks english the same just like not everyone programs the same now go annoy someone else troll

Use asymmetric encryption. A popular asymmetric encryption protocol is SSH. The JsCH library seems like a popular Java implementation of SSH.

thank you for your tips /i will have a look I understand that SSH is a secure protocol used for things such as VPNs and i am feeling it is a good idea to try and use that protocol...

  • 0

See you're saying to use the SSH protocol... You wouldn't use the SSH protocol unless you're communicating with an SSH server or making an SSH client.

All I'm saying is take a step back from what you're doing and look at the overall picture.

I'm not trolling, if anyone's trolling it's you 'how do i hide my code'.

SMH, welcome to the real world.

  • 0

See you're saying to use the SSH protocol... You wouldn't use the SSH protocol unless you're communicating with an SSH server or making an SSH client.

All I'm saying is take a step back from what you're doing and look at the overall picture.

I'm not trolling, if anyone's trolling it's you 'how do i hide my code'.

SMH, welcome to the real world.

Why can't a chat client and server communicate over SSH? SSH is (among other things) a protocol for secure data communication. There are no set limitations on what that data has to be.

  • 0

As far as I'm aware SSH is a tunneling communications protocol from an SSH client to an SSH daemon (running on a *nix system) which uses public and private RSA and ESSID keys to encrypt and decrypt the data sent to and from it, so if you were to use ssh then you'd ssh to a ssh server and run a program on it... The hassle of doing all that I can't see being worth it when you can just setup PGP easily, send over the public key and just use PGP or RSA.

  • 0

While you could make a chat client run over SSH, it's not a good "fit". Something like TLS is a much better option (You aren't dealing with SSH semantics then, it's just something that encrypts and decrypts incoming and outgoing communication)

  • 0

well then maybe you can help me..... I need to create a p2p chat system with encryption.... BUT the encryption key obviously cant be in the source code or sent over the internet in plain text ..... any helps ?

You need to step away from the code, and properly think about how the overall design will work.

Are you producing a client for existing protocols?

I get that this is probably just a personal programming exercise, but are you creating client software that is based on one or more existing chat protocols and infrastructures, and just throws encryption on top? Or are you creating entirely your own thing? I'm going to assume the latter!

So, will there be a web service?

How will users discover each other? How will they know when each other is online? And what about authentication?

While it would be possible to completely avoid having a web service (and maybe that's what you actually meant by 'p2p'), it would be a pain to use:

  • To connect to each other, users would have to communicate their IP address and port number to each other through some other means, and then enter this information into their chat clients.
  • Some people have dynamic IP addresses, and additionally the port number may not be fixed, so recording this information in a 'friends list' would be useless and therefore knowing whether each other is online without separately speaking to each other would be impossible.
  • If a user's IP address is dynamic and changes part way through a chat, their new IP address is going to have to be provided to the other user all over again, and a portion of the chat may have been lost in the interruption.
  • NAT could complicate things even more.

A third-party dynamic DNS service could perhaps make some of this easier, but adds problems of its own, and there's a better option - a centralised web service.

A centralised web service will allow users to connect to one another in a simple and clean manner.

  • Users will create a unique alias on the web service and then enter it into their client. The client software can automatically talk to the web service to provide/update the IP address and port number to associate with it.
  • Periodic checks by the service, or "check ins" generated by the client, are done to keep track of the user's connection status.
  • Tying a password to the alias prevents identity theft / impersonation.
  • One user would still need to disclose a piece of information (their alias) to the other user in order to create the initial connection, but there's no getting around that. Thankfully this way is much better than above though, and with a connection established, the users can be recorded in each other's 'friends list' and they never have to supply it again. If you think your users would accept it, you could even offer an email search/lookup facility, with a friend request mechanism.

A couple of notes:

  • In storing a friend list, the unique ID (aka UID, normally a number) should be recorded (hidden), not the alias, to allow users to change their aliases without breaking friend list entries.
  • If one user decides to remove someone from their friend list, you may want to consider automatically removing them from the other person's too.

So how to go about encrypting chat then?

As already pointed out by others, asymmetric encryption is the best way of implementing this, and I hope and assume that you're already familiar with it. We need to think about some specifics though!

One thing that may influence how you implement encryption will be legislation (if we're pretending that you were developing a real product here). Your government may not actually allow you to produce an encrypted chat mechanism with no means what-so-ever of allowing them to snoop on it. Let's pretend that there would be no such restrictions though.

One simple way of implementing asymmetric encryption could be by using an encryption key belonging to the web service as a 'legitimate' middle man, and dynamically creating client certificates on the fly. A copy of the web service's public key could be embedded in the client application (preventing a third-party middle man attack in transmitting it). When connecting to the service, the client creates a new certificate, encrypts the public key with the web service public key, and sends it to the web service, which then sends back an encrypted confirmation. In transmitting a message to the other user, the client encrypts it and sends it to the web service in the same way. The web service decrypts it, re-encrypts it with the public key for the other user, and sends it on.

There are two huge problems here though:

  • The huge load placed on the web service. This could very easily be solved by only using the above mechanism to transfer the user's public keys securely to each other, then they can send encrypted communications between themselves, but does not solve the next problem below.
  • The web service is a huge weak spot. Administrators of the web service can snoop at any time they like. The government can demand to be provided access to be able to snoop. If someone should hack the web service, they can snoop.

This kind of problem exists in a lot of systems out there. Drop box for instance, there's nothing really stopping administrators accessing your data unless you pre-encrypt it, which is a pain. HTTPS is a complete joke, and so therefore is S/MIME which afaik is based on it. There are a couple of excellent solutions though that we could derive inspiration from:

  • One is spideroak, a competitor to dropbox (no, before you ask, I don't work for them). Spideroak encrypts all of your data, and keep a copy of the encryption key, but they never keep a copy of the password for the encryption key. If you loose your password, you loose your data. As long as they are true to their word, and the software really operates as they say it does, never sending your password to them or anyone else, your data is completely secure.
  • PGP based email encryption. This is asymmetric encryption. Each user generates a key pair. They send a copy of their public keys to each other, and verify them (to ensure no-one has intercepted them and performed a switch) through another form of communication. This is completely secure as long as correct verification is done, and they keep their private keys secure.

We could improve the security of our chat application by copying PGP. (I think there's actually an existing plugin for Pidgin that does this). The client allows the user to generate a key pair, and the public key could automatically be sent to anyone you connect to. You use another means such as the phone to verify them, and you're secure. Public keys could also be stored in friend lists, and signed by the user, in order to record the fact that they have verified and can trust that key, so you don't need to verify it every time, and so that if the developer of the client (you) tried to switch the key to snoop, they'd notice. Users would still need to trust that the client application isn't leaking unencrypted chat content or their private keys back to the developer (you) or government, but it wouldn't be too difficult for an expert to analyse the binary of your application and the web traffic it generates in order to determine if anything fishy is going on. (It would not be possible to analyse the web service described earlier is this way, an analyst would have to be granted special access to it, and you could easily hide things or change them at any time you liked).

The design outlined is not necessarily perfect however, because the user's key is stored locally on their computer. If they want to use a different computer, or loose their computer for any reason, that's a problem for most users. It would probably be better if user encryption keys (public and private) were stored on the web service. The public key could be stored as is, just like a public public-key server, and record signatures placed on keys, allowing groups of friends to more easily establish trust within their group with fewer external verification checks needed. The private keys would be encrypted with the user's password, and the password would never itself be stored by the web service, just like spideroak. When the user logs in to their chat client, a mechanism is gone through to that authenticates the user, crucially without their password being submitted to the web service, and hopefully without unnecessarily handing out a copy of the private key to anyone without the correct password. This sounds difficult if not impossible but spideroak apparently manages to do exactly this! Additionaly the transfer of the private key once the user is authenticated must be done securely, perhaps the copy of the already encrypted copy could be sent, and then decrypted with the password in the client...but then why wouldn't spideroak simply do that...I think I need to get some sleep at this point, and think this bit through some other time...

One potential problem with this improved mechanism though is that for security, users cannot log in to the website (pretending one existed for the product), if logging in to it was needed for some particular functionality, without compromising their security. Spideroak strongly advise against logging in to the website, instead doing everything within, or establishing an authenticated web session through, their application.

I'm probably going way beyond what you perhaps wanted with this, but it was interesting to think about :p

What about saved chats?

This can wait for another time, It's really late now and I should get some sleep...!

-----

edit: fixed a few minor typos and a broken link

  • Like 2
  • 0

You need to step away from the code, and properly think about how the overall design will work.

Are you producing a client for existing protocols?

I get that this is probably just a personal programming exercise, but are you creating client software that is based on one or more existing chat protocols and infrastructures, and just throws encryption on top? Or are you creating entirely your own thing? I'm going to assume the latter!

So, will there be a web service?

How will users discover each other? How will they know when each other is online? And what about authentication?

While it would be possible to completely avoid having a web service (and maybe that's what you actually meant by 'p2p'), it would be a pain to use:

  • To connect to each other, users would have to communicate their IP address and port number to each other through some other means, and then enter this information into their chat clients.
  • Some people have dynamic IP addresses, and additionally the port number may not be fixed, so recording this information in a 'friends list' would be useless and therefore knowing whether each other is online without separately speaking to each other would be impossible.
  • If a user's IP address is dynamic and changes part way through a chat, their new IP address is going to have to be provided to the other user all over again, and a portion of the chat may have been lost in the interruption.
  • NAT could complicate things even more.

A third-party dynamic DNS service could perhaps make some of this easier, but adds problems of its own, and there's a better option - a centralised web service.

A centralised web service will allow users to connect to one another in a simple and clean manner.

  • Users will create a unique alias on the web service and then enter it into their client. The client software can automatically talk to the web service to provide/update the IP address and port number to associate with it.
  • Periodic checks by the service, or "check ins" generated by the client, are done to keep track of the user's connection status.
  • Tying a password to the alias prevents identity theft / impersonation.
  • One user would still need to disclose a piece of information (their alias) to the other user in order to create the initial connection, but there's no getting around that. Thankfully this way is much better than above though, and with a connection established, the users can be recorded in each other's 'friends list' and they never have to supply it again. If you think your users would accept it, you could even offer an email search/lookup facility, with a friend request mechanism.

A couple of notes:

  • In storing a friend list, the unique ID (aka UID, normally a number) should be recorded (hidden), not the alias, to allow users to change their aliases without breaking friend list entries.
  • If one user decides to remove someone from their friend list, you may want to consider automatically removing them from the other person's too.

So how to go about encrypting chat then?

As already pointed out by others, asymmetric encryption is the best way of implementing this, and I hope and assume that you're already familiar with it. We need to think about some specifics though though!

One thing that may influence how you implement encryption will be legislation (if we're pretending that you were developing a real product here). Your government may not actually allow you to produce an encrypted chat mechanism with no means what-so-ever of allowing them to snoop on it. Let's pretend that there would be no such restrictions though.

One simple way of implementing asymmetric encryption could be by using an encryption key belonging to the web service as a 'legitimate' middle man, and dynamically creating client certificates on the fly. A copy of the web service's public key could be embedded in the client application (preventing a third-party middle man attack in transmitting it). When connecting to the service, the client creates a new certificate, encrypts the public key with the web service public key, and sends it to the web service, which then sends back an encrypted confirmation. In transmitting a message to the other user, the client encrypts it and sends it to the web service in the same way. The web service decrypts it, re-encrypts it with the public key for the other user, and sends it on.

There are two huge problems here though:

  • The huge load placed on the web service. This could very easily be solved by only using the above mechanism to transfer the user's public keys securely to each other, then they can send encrypted communications between themselves, but does not solve the next problem below.
  • The web service is a huge weak spot. Administrators of the web service can snoop at any time they like. The government can demand to be provided access to be able to snoop. If someone should hack the web service, they can snoop.

This kind of problem exists in a lot of systems out there. Drop box for instance, there's nothing really stopping administrators accessing your data unless you pre-encrypt it, which is a pain. HTTPS is a complete joke, and so therefore is S/MIME which afaik is based on it. There are a couple of excellent solutions though that we could derive inspiration from:

  • One is spideroak, a competitor to dropbox (no, before you ask, I don't work for them). Spideroak encrypts all of your data, and keep a copy of the encryption key, but they never keep a copy of the password for the encryption key. If you loose your password, you loose your data. As long as they are true to their word, and the software really operates as they say it does, never sending your password to them or anyone else, your data is completely secure.
  • PGP based email encryption. This is asymmetric encryption. Each user generates a key pair. They send a copy of their public keys to each other, and verify them (to ensure no-one has intercepted them and performed a switch) through another form of communication. This is completely secure as long as correct verification is done, and they keep their private keys secure.

We could improve the security of our chat application by copying PGP. (I think there's actually an existing plugin for Pidgin that does this). The client allows the user to generate a key pair, and the public key could automatically be sent to anyone you connect to. You use another means such as the phone to verify them, and your secure. Public keys could also be stored in friend lists, and signed by the user, in order to record the fact that they have verified and can trust that key, so you don;t need to verify it every time, and so that if the developer of the client (you) tried to switch the key to snoop, they'd notice. Users would still need to trust that the client application isn't leaking unencrypted chat content or their private keys back to the developer (you) or government, but it wouldn't be too difficult for an expert to analyse the binary of your application and the web traffic it generates in order to determine if anything fishy is going on. (It would not be possible to analyse the web service described earlier is this way, an analyst would have to be granted special access to it, and you could easily hide things or change them at any time you liked).

The design outlined is not necessarily perfect however, because the user's key is stored locally on their computer. If they want to use a different computer, or loose their computer for any reason, that's a problem for most users. It would probably be better if user encryption keys (public and private) were stored on the web service. The public key could be stored as is, just like a public public-key server, and record signatures placed on keys, allowing groups of friends to more easily establish trust within their group with fewer external verification checks needed. The private keys would be encrypted with the user's password, and the password would never itself be stored by the web service, just like spideroak. When the user logs in to their chat client, a mechanism is gone through to that authenticates the user, crucially without their password being submitted to the web service, and hopefully without unnecessarily handing out a copy of the private key to anyone without the correct password. This sounds difficult if not impossible but spideroak https://spideroak.co...do exactly this! Additionaly the transfer of the private key once the user is authenticated must be done securely, perhaps the copy of the already encrypted copy could be sent, and then decrypted with the password in the client...but then why wouldn't spideroak simply do that...I think I need to get some sleep at this point, and think this bet through some other time...

One potential problem with this improved mechanism though is that for security, users cannot log in to the website (pretending one existed for the product), if logging in to it was needed for some particular functionality, without compromising their security. Spideroak strongly advise against logging in to the website, instead doing everything within, or establishing an authenticated web session through, their application.

I'm probably going way beyond what you perhaps wanted with this, but it was interesting to think about :p

What about saved chats?

This can wait for another time, It's really late now and I should get some sleep...!

well I will answer the first two sub titles :p the 3rd one will require more reading but I have to get my washing out before i go to class xD ......

firstly thank you for taking the time to show interest it shows you are taking me seriously...

secondly This is my aim and how I am trying to get there...

this P2P connection will have a host so far im starting off easy, the host will be decided by the people using the chat (e.g. run host.class)

the host will be listening on the desired port (default probs 4444 or 5555 something like that) the client then connects to host ... yes target will need to be specified by client (I am trying to do this with as little database work as possible but I am not closed to it )

this program is not designed for use by a large populous its a program that will be off the radar for now and used for specific private communications....

I was thinking about using private and public key methods but im not sure how they work yet....

There will be another chat I will be making in the future which will use usernames and such both with encryption and without (one is a project I have to do other is just because I want to ) ....

like I said rest will have to wait!!! also no saved chats ever ! all will be burnt ...

  • 0

even when I encrypt with DES both times i still get the same result ...the thing is im trying to set up a safe way to send information where neither party has the others keys so encryptions needs to be removed in the same order they were added .... so if i encrypt the string "moo" ... with a passkey such as "hello" then encrypt the new string with the passkey "goodbye" I then need to remove the encryption "hello" after which i then remove the passkey goodbye .... :p get it?

What you're talking about is mathematically possible, however I don't think it can be secure. The only way (that I know of) to do this is is with very simple algorithms (hence the lack of security). Take, for example the XOR bitwise operation. With a simple XOR cipher, you can encrypt a text with a key K1, and then again with a key K2. To decrypt, you can use K1 and K2 in any order.

I would, however, suggest following the lead of existing open source software that fits with your goals. Given your current knowledge, it's basically impossible to invent a novel cryptographic approach.

If I have seen further it is by standing on the shoulders of giants. --Isaac Newton

  • 0

What you're talking about is mathematically possible, however I don't think it can be secure. The only way (that I know of) to do this is is with very simple algorithms (hence the lack of security). Take, for example the XOR bitwise operation. With a simple XOR cipher, you can encrypt a text with a key K1, and then again with a key K2. To decrypt, you can use K1 and K2 in any order.

I would, however, suggest following the lead of existing open source software that fits with your goals. Given your current knowledge, it's basically impossible to invent a novel cryptographic approach.

If I have seen further it is by standing on the shoulders of giants. --Isaac Newton

ye I know it is possible I went to a seminar about this kind of stuff ... though we talked about methods and ideas they never really shared how to do it xD which is annoying so I know its possible these people are contractors for the DoD ....I am going to try public and private keys to see where that gets me though I dont want to use it without knowing exactly how the mathmatical algorithms work it seems like an odd concept ... once I read the logic behind it i will be fine ....

"with great power comes great responsibility" -- ben parker

  • 0

:woot: best post in this entire forum since a long while.

I know right someone who shows interest and posts a length post !

also question for you!

I cannot understand why this is refusing to work


KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(1024); //it complains about this line, "miss placed constructs, delete token 1024?
KeyPair kp = kpg.genKeyPair();
Key publicKey = kp.getPublic();
Key privateKey = kp.getPrivate();

[/CODE]

  • 0

package enchat;
import java.security.*;
import java.security.spec.*;
import java.io.*;
import java.math.*;
public class RSAe {

KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(1024);
KeyPair kp = kpg.genKeyPair();
Key publicKey = kp.getPublic();
Key privateKey = kp.getPrivate();
public static void main(String[] args) {


}

}
[/CODE]

  • 0

So it's not. That line of code has to be inside a method, this is just a rule of the Java language. At the class level you can only have method or field declarations, and field declarations can optionally have an initializer. That line of code is neither.

  • 0

So it's not. That line of code has to be inside a method, this is just a rule of the Java language. At the class level you can only have method or field declarations, and field declarations can optionally have an initializer. That line of code is neither.

oooooh derp ... I did something stupid didnt I, I facepalmed when I realised I am not thinking at all .... (its been a while since i last slept)

This topic is now closed to further replies.
  • Posts

    • Ooooh! Two editorial from Paul Hill on the same day! Is it my birthday or something? 😉 Okay, let's see if I get it right. SearXNG develops a meta-search engine app. Individuals install it on their relays. Users connect to these relays to have their own identity-stripping meta-search engine instead of relying on DuckDuckGo. And some of these volunteers have listed their SearXNG instances on SearX.space. That was a lot of wrap my head around. I hope I haven't missed anything.
    • You sound like some Ukrainians in Crimea before 2014: "I didn't vote for USSR disbanding - I want Ukraine to be part of Russia again" 🤣
    • Uninstalr 3.1 by Razvan Serea Introducing Uninstalr: Easy to use and very accurate software uninstaller for Windows. It can uninstall multiple apps at the same time and we think it’s pretty cool. Developed with expertise by Macecraft Software - the minds behind jv16 PowerTools. Key Features Batch uninstall many apps at the same time. Supports unattended uninstallation of apps. Supports monitoring of new software installations. Also detects portable apps and previously uninstalled software leftovers. Shows all the data added to your system by installed software on a file by file basis. Shows all the data it will remove before starting the uninstallation. Filter and search the list of installed software. According to our benchmark, Uninstalr is the most accurate software uninstaller by leaving the least amount of leftovers when uninstalling apps. Supports detection and uninstallation of Microsoft Store, Steam, Big Fish Game System, Chocolatey, NuGet and Ninite installed software. Supports Windows Dark Mode. Supports Windows 11, 10, 8 and 7. Comes with these translations builtin: Chinese Simplified, Chinese Traditional, Czech, Danish, English, Filipino, Finnish, French, German, Greek, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Romanian, Slovak, Spanish, Swedish, Thai, Turkish, Ukrainian and Vietnamese. Has a single executable file portable version and a normal setup version. Uninstalr is freeware, lightweight and easy to use. No bells and whistles, no nonsense. Uninstalr’s custom uninstallation engine has a dedicated support for the detection and uninstallation of 15 types of apps: Normal Windows apps Microsoft Store apps Portable apps Chocolatey apps Ninite apps PortableApps.com apps Steam games EA App games Epic Games Store games Riot platform games GOG Galaxy games WarGaming.net games Battle.net games itch.io games Big Fish platform games Uninstalr 3.1 changelog: Key Changes Uninstalr now starts and shows the list of installed apps faster after the initial scan has been completed, and with much smaller memory usage. Uninstalr now detects and highlights apps that automatically start with Windows. Greatly improved the detection of portable apps. Improvements New feature: Uninstalr now detects and highlights apps that automatically start with Windows. New feature: Uninstalr now highlights possible leftovers and apps from Russia and China. This can be disabled from the Settings. New feature: A new filter that allows you to show only software that is installed to other than the system drive. New feature: Users can now select to always do the deepest and the most accurate scan for installed apps, at the cost of the analysis taking a longer time. Greatly improved the detection of portable apps, such as added dedicated support for MiTeC, EZ Tools and SysInternals tools. Improved support for portable apps installed via Windows System Control Center (WSCC). NirSoft portable apps are now listed with "NirSoft" prefix for easier identification. Improved the speed of uninstalling apps. The main installed software listing search will now find "Xbox GameBar" if you search for "Game bar" and vice versa. The tooltip now displays more detailed information of the installed apps, such as its registry key and uninstaller path. The links in the About section now look more like clickable links. The main menu is now more clearly indicated in the main user interface. Microsoft Teams Meeting Add-in for Microsoft Office ships with some Windows 11 installations and is now considered a builtin Windows app and only listed if builtin Windows apps filter is enabled. Added a Help button to the main user interface that opens the help section of the website. Added an option not to close Uninstalr after uninstallation. If you open the Uninstalr website from the app, the website now receives the version number of your current Uninstalr version and warns you if you are using anything but the latest version. Improved the accuracy of the New Software Monitor. Improved confirmation messages for Steam and other platform related uninstalls. Improved the uninstallation performance of Steam games. Fixes: Known bug fixed: Some installed app names are capitalized incorrectly, such as "CCleaner Portable" is listed as "ccleaner portable". Known bug fixed: Some apps can be listed twice, for example, Smart Defrag can be listed once as Smart Defrag and then Smart Defrag Home. Known bug fixed: On the pre-uninstallation screen, the Scripts checkbox can be checked by default on Dark Mode but not on the normal mode. Known bug fixed: Perform Deep Analysis can be started only by clicking the button, not via the Right Click menu, main menu or F4 keyboard shortcut. Muse Hub could be incorrectly listed as Adobe Muse. SyncTrayzor was incorrectly detected as two unrelated software, SyncTrayzor and Syncthing. Smart Defrag was incorrectly listed twice as Smart Defrag 11 and Smart Defrag Home. It was possible to enter non-printable characters to the search input boxes of the main screen, and the path listing screen, which caused the UI to look funny. Changing the translation from Settings, especially many times in a row, caused the UI to distort. If you had multiple instances of portable apps on your system, such as the 64b and 32b versions of the same portable app, typically only one of them was detected, not both. In some very rare cases, Uninstalr UI could start with random characters in its search input boxes, which could make the UI look rather confusing. This was a rare issue, only reported by two users. The pre-uninstallation screen could display non-existing paths for example as the software's installation directory or main exe file. This was a cosmetic issue. New Software Monitor cannot detect the installation of Claude. Selecting all the found software made the UI look funny with the top panel covering everything else (because the names of all the selected software were listed there). Sometimes a Steam game could be listed a normal app instead of a Steam game. If the system restart after an uninstallation is delayed, e.g. because of Windows Updates being installed, this additional delay is incorrectly added to the time how long the uninstallation process took. This cosmetic bug could cause the program incorrectly report an uninstallation time longer than the actual uninstallation time. Uninstalling Minecraft could simply fail. The Only scan the system drive for installed apps setting does not fully work. If some apps are installed to a non system drive and this setting is enabled, the app could still be detected and listed on the main user interface. Changing any settings could also incorrectly alter the Only Scan The System Drive For Installed Apps setting. Microsoft OneDrive and Copilot are not always detected. If you enter something to the search filter field, then select the text and press the Delete key, this triggers the Uninstall button click even if your intent was to delete the text input. If you press the F5 key to refresh the screen during the uninstallation loading screen, the program will crash. If you enabled some setting, such as "Do not analyze installed app installation sizes", it could automatically be unchecked later. Uninstalr doesn't warn you if you try to remove Fortec antivirus. There should be a warning if user attempts to remove any antivirus or antimalware type program. Such programs should not be uninstalled using a third party uninstaller, as they are typically protected against automated uninstallation, for security reasons. With "Do not analyze installed app installation sizes" option checked from the Settings, Uninstalr could still display some installation size related elements in the UI which was confusing. The "Only scan the system drive" option moved under Improve Scan Speed from the General settings. If two software have the exact same name and version number, selecting both of them for uninstallation fails because only one is actually selected. Sorting the installed apps by size sometimes fails and the order is incorrect. The "Don't show which paths are currently analyzed" did not work correctly - some parts of the UI still show the currently analyzed path with this setting checked. The "Don't list software less than 10 MB" filter did not work correctly - some apps smaller than 10 MB could still be listed. Uninstalr could start very quickly and display an empty list of detected apps. Restarting the app usually fixed the issue and the list of installed apps was properly displayed. If you placed portable Uninstalr to a same folder with other portable apps, those were not detected because Uninstalr automatically added its installation folder to the ignore list. When trying to uninstall some specific software, Uninstalr could get stuck on the Searching for more data relating to the app phase. Uninstalr could sometimes do a silent uninstallation even if user had unchecked the Perform a silent uninstallation option. Known issues: Uninstalr can fail to run with an Out Of Memory error in systems that have a lot of installed apps. Using the New Software Monitor tool multiple times during one session can cause the program to get stuck on the Scanning stage. The "uninstallation completed" message box sometimes closes when the user moves the mouse cursor over the button before user clicks it. There is no feedback for the user after Fix Information feature has been used. The Right Click menu's Select by publisher option can display the number of apps per each publisher without correct vertical alignment. The default user interface might not display all of the found installed apps if you have over 600 installed apps. If you do, using the Screen Reader Compatible Interface solves the issue. Leftover apptype filter checkbox is shown in red font only in Dark Mode. Clicking the app's icon from the Windows Taskbar doesn't minimize/restore the app like other apps. The warning about an app that user wishes to uninstall being related to some other app user did not select can sometimes be inaccurate. If app's language is changed without restarting Uninstalr, the list of installed software might not automatically refresh. When software is being uninstalled, the UI can say it is processing paths unrelating to the uninstalled app. This is purely cosmetic and does not mean these paths are removed. Uninstalr might not properly detect and/or uninstall Steam games if they are installed to a drive different than Steam's default location in C:\. You might see "This action is only valid for products that are currently installed" error message from Windows Installer during uninstallation. This is a cosmetic issue. Download: Uninstalr 3.1 | 7.1 MB (Free, paid version available) Download: Uninstalr Setup 3.1 View: Uninstalr Website | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • I and many others did not vote to get out of the E.u because of Putin or Farage, we did so for our own reasons. You don't have to tel me what my own did or did not do when it comes to the E.U. The EEC is or was the European Economic Community, a different beast to what the E.U is now.The EEC was a mainly about trading, the E.U have gone far beyond that and as I have said before, is now more of a United States of Europe. The U.K did not vote to join a United States of Europe. Anyway, they did not want us in there in the first place, Charles de Gaulle stopped us joining as he claimed we didn’t agree with the core ideas of integration. He was not wrong and that is why we voted out of the E.U when the time came. I was not old enough to vote the first time. My only regret is that we did not have the referendum years ago and got out years ago. If we rejoined, we would have to agree to join the Euro and no doubt Schengen, agree with freedom of movement, we have enough problem with people coming over here as it is. i have no problem with people coming over here if they work and don't try to push their way of life onto us. The E.U has a currency, freedom of movement, an anthem a flag, a parliament, well they are there, not sure if they do anything. Don't sound like something that is just for trading. Oh yeah, also wanted a euro Army. How many stupid rules have the E.U made that we had to follow? I doubt I will see the Uk rejoin the E.U, which suits me. Oh yeah, my partner is Polish, she came over here before Poland joined the E.U and she got fed up of people just coming over here with ease, while she had to struggle. She is now a British citizen and have been for a fair few years
    • Hello, Paul. Thanks for the editorial. It was interesting. I'm going research more into the app and its concept. Of course, if you know me at all, you know that I'd say your articles needs some editing! I always do, don't I? For instance, the article occasionally mentions relays before defining it.
  • Recent Achievements

    • Week One Done
      flexorcist earned a badge
      Week One Done
    • One Month Later
      Woland13 earned a badge
      One Month Later
    • Week One Done
      Woland13 earned a badge
      Week One Done
    • One Year In
      bernmeister earned a badge
      One Year In
    • Week One Done
      Scoobystu earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      495
    2. 2
      +Edouard
      226
    3. 3
      PsYcHoKiLLa
      153
    4. 4
      Steven P.
      75
    5. 5
      FloatingFatMan
      71
  • Tell a friend

    Love Neowin? Tell a friend!