How and where to store a SecretKey

S

Stefan Ram

David Segall said:
I might store the key or what format it is in

The key is not »in a format«.

It is an object.

An object is being defined by its behavior.

Some objects have a state that can be serialized
(written) and be deserialized (read) later.

If this applies, it should be possible to learn
more about it in the documentation of the class
of the object.

(Notwithstanding the question whether it is wise
to store a secret key in a database.)
 
A

Arne Vajhøj

David said:
The typical tutorial on Java encryption such as
<http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html#SimpleEncrEx>
shows you how to generate a SecretKey and use it immediately to
encrypt and decrypt some text. I have not found any guidance on where
I might store the key or what format it is in. How can I store the key
in a database or in a property list?

SecretKey is serializable and can be stores as such.

But I think it is much more common to store the bytes used
to construct the SecretKey (SecretKeySpec).

Where to store it depends on the context.

Arne
 
R

Roedy Green

The typical tutorial on Java encryption such as
<http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html#SimpleEncrEx>
shows you how to generate a SecretKey and use it immediately to
encrypt and decrypt some text. I have not found any guidance on where
I might store the key or what format it is in. How can I store the key
in a database or in a property list?

A good place to put it would be a thumbdrive. That way it all trace
of it is gone from the computer, and unavailable to hackers.

see http://mindprod.com/bgloss/thumbdrive.html

A thumbdrive just looks like a tiny hard disk to Java.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top