This code generates a pair of public/private keys:
KeyPairGenerator keyGen = KeyPairGenerator.getInstance(\"RSA\");
keyGen.initialize(1024);
KeyPair keypair = ke
If you want to define a format for storing the keys, then I would choose a format that is expendable so that it doesn't break when you want to change encryption (when the old one gets to weak for example).
So i would store the bytes encoded as base64, together with a string that describes the format, "rsa" maybe.