java - Best approach to generate a dynamic key in security -


this question has answer here:

a defined key used in this example:

byte[] keybytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,     0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 };  secretkeyspec key = new secretkeyspec(keybytes, "aes"); 

i need know recommended approach generate dynamic enhanced unpredictable key, when security working jax-ws , jax-rs web services.

that's securerandom class in java for:

securerandom random = new securerandom(); byte[] key = new byte[24]; // 24 or whatever key length random.nextbytes(key); 

securerandom provides "a cryptographically strong random number generator (rng)" according javadoc documentation. it's faulted being slow, not being insecure.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -