Search code examples
javaidentifier

How can I generate a string similar to YouTube's video identifier string in Java?


Edits: I reworded this question.

I notice that at YouTube, each video has a unique string such as 1cru2fzUlEc to identify itself.

I am wondering how I can do the same thing efficiently in Java.

Thanks for any input.

Cheers!


Solution

  • As Patashu already pointed out: These strings are not encrypted they are simply unique identifiers which cannot be guessed or calculated.

    This can be achieved in Java using the UUID implementation. These UUIDs are longer than youtube's but the principle is the same.

    The security of these UUIDs should be good enough for almost all occasions, as has been discussed here.