I would like to generate a random password of a defined length which can easily be typed in with a standard keyboard.

As a start I tried the following:

StringJoin[RandomChoice[CharacterRange[33, 126], 10]
(* "=IP@7mbYcB" *)

Do you know other solutions?

  • 1
    $\begingroup$ "欲穷千里目,更上一层楼。"means “Yqqlm_Gs1cl”.I'm sure anyone cannot broke it.And it is easy to remember. :) $\endgroup$
    – yode
    Commented Jul 20, 2017 at 3:56

2 Answers 2


A shorter formulation equivalent to your own code is:

FromCharacterCode @ RandomInteger[{33, 126}, 10]

However quite a few places only accept alphanumeric passwords, and not all keyboards have the same easily accessible character sets. If we assume that your given example is sufficiently secure you need 94^10 ~= 5*10^19 unique passwords. This is easily accomplished by adding a single alphanumeric character as 62^11 ~= 5*10^19. Therefore I propose:

rnd =
  FromCharacterCode @ 
    RandomChoice[Join @@ Range[{48, 97, 65}, {57, 122, 90}], #] &;


Or five passwords at once:

rnd[{5, 11}]
{"suPwm0c7FxS", "CV3khXaowWS", "Lac9z1IVCwc", "gptfkp2GMwH", "HDhRuFPLxte"}
  • $\begingroup$ Could you remember anyone? :) $\endgroup$
    – yode
    Commented Jul 20, 2017 at 14:54
  • $\begingroup$ @yode One? Yes. A significant number? No. My strategy is to use a password manager that effectively locks away a list of passwords behind a single one. There is no way I could remember a large number of high quality passwords no matter the scheme used. $\endgroup$
    – Mr.Wizard
    Commented Jul 20, 2017 at 21:59

Here's something which is nice and might be easy to remember:

StringJoin @@ RandomSample[#, Length@#] &@
 Flatten@{IntegerString@RandomInteger[{10, 999}],
   Capitalize /@ RandomWord[3],
   RandomSample[Characters@"!@_%$^=+*.", 2]

Select examples:

"Tearless+PostdoctoralDragon=635" (*DEFINTIELY MY FAVORITE!!*)


To increase the entropy, you may want to make spelling mistakes. Here's a great way to produce pronounceable non-words:

spoilWord[word_String] := 
  RandomChoice@{"Hebrew", "Arabic", "Japanese", "Korean","Greek"}


  • $\begingroup$ This is a really funny solution ... I like it very much. $\endgroup$
    – mrz
    Commented Jul 20, 2017 at 3:53
  • $\begingroup$ To increase entropy, you can also just add one or two more all lowercase, space-separated words. "a thought that never changes remains a stupid lie" is a very secure password that's both easy to remember and type. (Okay, depends, if someone knows I'm using verses from lyrics of songs I can randomly recall that will probably reduce the search space significantly compared to "ten random words.") $\endgroup$
    – millimoose
    Commented Jul 20, 2017 at 10:00
  • $\begingroup$ I would personally get rid of the extra punctuation - it's more to remember for very little entropy gain. $\endgroup$
    – corsiKa
    Commented Jul 20, 2017 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.