fgonzalez fgonzalez - 1 year ago 177
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?


Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download