this function generates random string for given length @param length Desired length @return
(int length)
| 262 | * * @return |
| 263 | */ |
| 264 | public static String generateRandomIV(int length) |
| 265 | { |
| 266 | SecureRandom ranGen = new SecureRandom(); |
| 267 | byte[] aesKey = new byte[16]; |
| 268 | ranGen.nextBytes(aesKey); |
| 269 | StringBuffer result = new StringBuffer(); |
| 270 | for (byte b : aesKey) { |
| 271 | result.append(String.format("%02x", b)); //convert to hex |
| 272 | } |
| 273 | if(length> result.toString().length()) |
| 274 | { |
| 275 | return result.toString(); |
| 276 | } |
| 277 | else |
| 278 | { |
| 279 | return result.toString().substring(0, length); |
| 280 | } |
| 281 | } |
| 282 | } |
nothing calls this directly
no outgoing calls
no test coverage detected