safe enough 8-character short unique random string

前端 未结 7 1341
甜味超标
甜味超标 2021-02-01 01:34

I am trying to compute 8-character short unique random filenames for, let\'s say, thousands of files without probable name collision. Is this method safe enough?



        
相关标签:
7条回答
  • 2021-02-01 02:29

    Your current method should be safe enough, but you could also take a look into the uuid module. e.g.

    import uuid
    
    print str(uuid.uuid4())[:8]
    

    Output:

    ef21b9ad
    
    0 讨论(0)
提交回复
热议问题