Mark Mintoff My superpower is common sense

16Mar/112

Randomized String Generation

Sometimes, it comes to pass that we need randomized string generation; in my case I required a methodology for creating default passwords. I figured I'd create a random string generator.

The way this works is pretty simple. A string of allowed characters is defined, with booleans for whether uppercase, numbers or special characters are allowed.

Next a Random object is created and seeded with the HashCode from a new Guid. Whether this is necessary is debatable unless you need to create an arbitrary amount of randomized strings in a short period of time.

Next a for loop, setting random characters into the character array.

Finally returning of the string.

I decided to give this a spin and created 100, 15 character length "passwords" and the following is the result:

  1. jXcFBAsos4ARq-A
  2. byHuvoz3d3DpwR-
  3. eL@hneV_C2PaC?u
  4. gHW?NYbbs4mPj-N
  5. FYLp?$fWODXXJHB
  6. c52tfUNOSXDmtwp
  7. 3KCi1NnWi54fLPe
  8. v1Qi6obc?9QvwjU
  9. T3LCPCtCjjDq79e
  10. Nqu-5rnvinqL8pN
  11. QLduHt7UQ5Df7Sc
  12. _onMW@pKEf$y!CA
  13. DEFwc5KOWyD_sMv
  14. A2HQizx_hXffrCi
  15. nKd!wxtMNWJkdWK
  16. GPRDUPMnbx_$_eR
  17. duigUye7A_taO21
  18. DTsVcQrZNGjpGkn
  19. -SkPBRuhxA5MnV5
  20. kGeXGBLAcYqk2J5
  21. ARfj83xYHX0jtJM
  22. je$!PWJi8bX4eBF
  23. 2UhVCM9xZzPJu0-
  24. gd98j6LzK402xJd
  25. ru@y7Wp9Q_GLKZp
  26. W9McqnS6CMqnaTh
  27. fR3Y8mXDcrHKXyj
  28. 88py5Y-VNoTm4@F
  29. PUaB-AM_9Wrprwd
  30. wNaM1Zks_keMD0R
  31. P5fqdydAQ-9En22
  32. NzyiHQzq3U1nDP3
  33. sFWNiF-rJVLh!Ay
  34. APYj7@CUZGBmuLB
  35. ze?c7TrO5GB6ubr
  36. zmdn$f?7GQYV3SC
  37. _3WyuHE6iyNkN-0
  38. gvKqQrELMTUM_t8
  39. 02V@!DbHm4Mcf7@
  40. 6ALeyN@UqWsArpD
  41. ExpqKPO8qvUK-wN
  42. Lt6BKxrLkZ!!T@m
  43. 8eW_sKzCmcPV0eP
  44. cvWP7UMvi2y-ETD
  45. nZd2Ob@GSPVpJh_
  46. YpNpAHJi2p0TUd9
  47. BJN9Lg5esUz1tWa
  48. q$yEd_L@hM1Nm-M
  49. DV8!NAiB$S1QDL3
  50. @pzVLCXX_nXuTqX
  51. b9N7M$xk@HQLboK
  52. ZGg0@YtyjYuu0ZU
  53. rsvULnQV@h-9Poq
  54. 5MRr0_www89Gqb9
  55. Ov6wwvnDme9ULP6
  56. xXu6CnhR7Fjk8ic
  57. @OFGxhfzsmF0?JX
  58. Qg3BixRnR5mnOE@
  59. XdaWOCipDkSAvSs
  60. $Mg3nkEEyUmFtbS
  61. ?LqfbEb@zio3Hw?
  62. 6f2xbdF45e2wMX!
  63. V0a5Y1t@G4aHfh6
  64. Xyb5yV$Hhv5QHDB
  65. QXTt-VJOisAxb98
  66. gNU09Uo8!b-CYwj
  67. fqPV__f4WBdDO1A
  68. @SGSZiP6kwTGWYA
  69. @98x4szrRJLAHD2
  70. kU1BUeUwA8as6ph
  71. ZuA!R4AnT-bkZi7
  72. rCtnO-@iakv468s
  73. L9EowwTXckW5o8j
  74. bY@kSKR1ECwgFK5
  75. j87aBayM2Sxx$@n
  76. mbB_yxf06m9$UA?
  77. pFAeGeFh!nLsrVW
  78. Qz?pOwhvis@$5ZL
  79. ZvQrOrK5gP5cfQS
  80. gtt8dV@EJCukRMP
  81. bh7-nkNPYbSHhRA
  82. @-x1Sh1hRn91iDo
  83. zanNydqG?E@YjFZ
  84. kRaHZ@?kps_XPhh
  85. NOg!6Q3h$m$MYac
  86. PLw-MRQGrx_3y$L
  87. 8zxmcJ1UVnFjp-_
  88. MvvHfsXao94Z9dM
  89. MZt-nLn1m-1km4h
  90. niUcgX0ajYZQ6wA
  91. H?BVTBycLa?iPRP
  92. PvJCUb2?vPP8t8i
  93. qGf2Q9LDdQKZtrh
  94. Egcm4RSXQJUZ-2S
  95. v0eeLVQb?QhE8S9
  96. gvMYD9k_EjWzcTR
  97. jnN3V@5qPQRriNO
  98. rA3EX3PJ_H567dQ
  99. Vvy!QxqBys86nnh
  100. VmxVbOn2A?3Wgif

Not too shabby eh?

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)