fgonzalez fgonzalez - 2 months ago 11x
Node.js Question

Generate unique key in Java

We are migrating a server project coded using NodeJs to one coded in Java. I'm not very into the cryptography thing but I need to "translate" the following instruction to Java.


Basically in the node js project they were using the js library crypto to generate a unique key, and I would need to do the same, no more, no less, in java.
Anyone with crypto knowledge that can help here? What would be the equivalent in Java?



You can use

Random.nextBytes(byte[] bytes) 

to populate a random byte array and then convert the bytes to hex using the strategies discussed here