java - Best approach to generate a dynamic key in security -
this question has answer here: how create secure random aes key in java? 3 answers 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.