I'm trying to make a program which uses RSA encryption to encrypt and decrypt data sent to and from multiple computers. I have a folder which stores the public keys of other computers, on my computer. I can't however, seem to load this key file and create a publicKey object which points to it. My current attempt is shown below but I was wondering what methods other people use to do this?
//Returns the key of a friend (given as input)
public PublicKey getFriendsKey(String friend){
try{ObjectInputStream friendsKeyInput = new ObjectInputStream(new fileInputStream(programLocation + "/Text Files/encryptionKeys/" + friend + "PublicKey.key"));
PublicKey friendsKey = friendsKeyInput.readObject();
}
catch(Exception e){e.printStackTrace();}
return friendsKey;
}