I’m looking to be able to save a DES SecretKey to a file, so you can import and use it later on.
I’ve looked at a few routes, but they all seem a bit long winded, is there no conscise simple way of doing this?
I’m looking to be able to save a DES SecretKey to a file, so
Share
Not clear on a couple of things: how you’re generating the key, and what format you have the key in. If you don’t have the key you can use keytool (a utility which comes with jdk) to generate it and put it into a file called a keystore. You can also use the KeyGenerator class and the KeyStore class to programmatically do the same thing (both are documented pretty well and the KeyStore javadoc has an example which does exactly what you seem to want.)
A much less secure but easy way you can generate the key and put it into a text file as clear text. Then you can just access it using a BufferedReader. This is less secure because anyone with access to this file will know your key, but it’s a little easier.