Cache the contents of KeyStore and convert it to a InputStream?

The KeyStore is in some binary format. Converting it to a UTF-8 string is no good. You could use a ByteArrayInputStream which uses a byte buffer.

The KeyStore is in some binary format. Converting it to a UTF-8 string is no good. You could use a ByteArrayInputStream which uses a byte buffer.

But: in my opinion doesn't count when it comes to performance optimization. You should do some profiling to check whether this really impacts performance. Because it shouldn't.

The operating system does cache too and most probably won't read the same file from disk over and over again if it didn't change in the meantime. Programmers usually are extremely bad at judging which parts of a program are performance hogs and which aren't. Also: It has a reason that passwords usually are provided via char arrays: You have total control over the content of the array and can clear it once it isn't needed anymore.

The password should stay in memory as short as possible. You don't have that kind of control with simple strings (you don't know when they are garbage collected).

1. This really looks like premature optimization by the OP, and it really is not a good idea to maintain a cache of the keystore contents. – Vineet Reynolds Aug 18 '10 at 11:05.

Thanks for the responses. I am all for the below alternative. I would Load the keystore once and extract the SecretKey and assign to an instance or class variable of the class you are using and then use the SecretKey whenever one need to encrypt or decrypt.

This is not a forum. If you have some comments to an answer, you can add a comment. If you have to update the question, simply edit it.

– musiKk Aug 18 '10 at 12:25 Well since I found a solution , I posted it . I don't see any harm nor I don't see any part of my post violating the stackoverflow rules. – Sudhakar Aug 25 '10 at 12:54.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions