I'm creating a random password generator in java and need some help with how I can generate random char values in the program. Any ideas? I'm using a menu system as a way to show different types of passwords to generate like lowercase, uppercase, etc.   Any advice would help.   Thanks!
13835
I've been looking for a simple Java algorithm to generate a pseudo-random alpha-numeric string.  In my situation it would be used as a unique session/key identifier that would "likely" be unique over 500K+ generation (my needs don't really require anything much more sophisticated).    Ideally, I would be able to specify a length depending on my uniqueness needs. For example, a generated string of length 12 might look something like "AEYGF7K0DM1X".
114462
I wonder whether for the average Linux user it is considered as bad -from a point of view of security or any other relevant viewpoints- to have no or almost no entropy left in /dev/random.   Edit: I don't need to generate random numbers (I would use /dev/urandom for that and even for password generation and disk encryption). Just for the fun of it, I have a bash script that generates strings of random characters out of /dev/random and of course, after playing a bit with it, I am left without entropy in /dev/random and it blocks. On IRC I was told it's "bad" to do so, but I wasn't given any reason. Is it bad because the average Linux user automatically generates random things using /dev/random? If so, which program(s) is/are involved?  I also understand that having no entropy left in /dev/random makes the generation of numbers deterministic. But again, is my computer (the average Linux user) in need of truly random numbers?   Edit 2: I've just monitored the entropy level every second in /dev/random during about 3 minutes, where I launched my bash script that uses entropy to generate a string of random character around the beginning of the monitoring. I've made a plot. We can see that indeed, the entropy level oscillates somehow, so some program(s) on my computer are using /dev/random to generate stuff. Is there a way I can list all programs using the file /dev/random?   We can also see that it takes less than a minute to yield "acceptable levels" of entropy once the entropy pool has been emptied.
61713
I'm struggling with coming up with an elegant solution to generating random events in the game that I'm working on.  Say there are 4 classes of events that can happen, with varying events in those classes that may occur.  So something along the lines of   main_events = {"common event", "not so common event", "somewhat rare event", "rare event"} sub_events[0] = {"common event 1", "common event 2",..} ...   I have a somewhat kludgey solution in place that first just has a random number generated between 0 and 100, and if the number falls within a given range then a main event will be triggered.  Then I'll do another random roll to see which sub event occurs.  Is there a better solution than something along these lines?  Like I mention, it doesn't feel very elegant, and I'd like to make it easily expandable for the addition of future events.
92159
I'm a Java head mainly, and I want a way to generate a pseudo-random number between 0 and 74. In Java I would use the method:  Random.nextInt(74)   I'm not interested in a discussion about seeds or true randomness, just how you accomplish the same task in Objective-C. I've scoured Google, and there just seems to be lots of different and conflicting bits of information.
41822
I need to generate a 256 bit encryption key described by the adjectives in the title. Currently I intend to create the key using this .  Is this a secure manner of creating the key, given that it has the following properties:   Private key for symmetric encryption Used many times (of course with unique IV's)   And given the following facts:   I will literally just get the RNG to produce 32 random bytes not doing anything with (1) SALT (2) Iterations (3) Anything else   Please note that I am only asking if the key, directly after being generated, is secure. Thanks
26810
How can I generate a (pseudo)random alpha-numeric string, something like: 'd79jd8c' in PHP?
56649
Wow, I've really done it this time. I've locked myself out of my machine.  In preparing for a Cherokee language course, I added the Cherokee keyboard layout to my options. However, I was unable to generate any Cherokee characters by selecting that input device.  I found an article on the web which instructed me to use the dpkg-reconfigure keyboard-configuration command in a terminal.  Once I did that, I rebooted as instructed. Once I was presented with the login screen, I entered my password as usual only for it to fail.  After failing a few times, I gave my attention to what is usually a mundane exercise (i.e., logging in).  While I carefully entered my password, each time, I get the message, "Sorry that didn't work..."  So, I brought up the onscreen keyboard... But the password box displays an asterisk for only the first character of my password.  I attempted to use the direct Unicode input method (ctrl-shift-Uxxxx) but the Cherokee keyboard has no "U" key.  Can anyone please help me troubleshoot this?
93317
I'm learning how to write programs in C using the k&amp;r book (The C Programming Language) and I have a problem with one of the exercises. It's asking me to detect and remove a character in string s1, which matches any characters in the string s2.  So, say s1 = "A";  And s2 = "AABAACAADAAE"  I want it to return "BCDE"  I know I'm on the right path towards it, i just don't know how to design programs very well, could you give me any additional tips. I tried to read about the binary search tree algorithm, but felt it was a little too advanced for this mundane task.  Thanks everyone!  /* An alternate version of squeeze(s1, s2) that deletes each character in  * s1 that matches any character in the string s2  *  * Angie@odfx.org  */  #include &lt;stdio.h&gt; #include &lt;string.h&gt;  void squeeze(char s[], char t[]);  char string[] = "BAD"; char sstring[] = "ABC";  int main(void) {     squeeze(string, sstring);     return 0; }  void squeeze(char s[], char t[]) {     int i, j, d;      d = 0;     if(strstr(s, t) == NULL)         printf("%c", s[i]);     s[j] = '\0'; }
113456
I'm writing a small article on humanly readable alternatives to Guids/UIDs, for example those used on TinyURL for the url hashes (which are often printed in magazines, so need to be short).  The simple uid I'm generating is - 6 characters: either a lowercase letter (a-z) or 0-9.   "According to my calculations captain", that's 6 mutually exclusive events, although calculating the probability of a clash gets a little harder than P(A or B) = P(A) + P(B), as obviously it includes numbers and from the code below, you can see it works out whether to use a number or letter using 50/50.  I'm interested in the clash rate and if the code below is a realistic simulation of anticipated clash rate you'd get from generating a hash. On average I get 40-50 clashes per million, however bare in mind the uid wouldn't be generated a million times at once, but probably only around 10-1000 times a minute.  What is the probability of a clash each time, and can anyone suggest a better way of doing it?  static Random _random = new Random();  public static void main() {     // Size of the key, 6     HashSet&lt;string&gt; set = new HashSet&lt;string&gt;();     int clashes = 0;     for (int n=0;n &lt; 1000000;n++)     {         StringBuilder builder = new StringBuilder();          for (int i =0;i &lt; 7;i++)         {             if (_random.NextDouble() &gt; 0.5)             {                 builder.Append((char)_random.Next(97,123));             }             else             {                 builder.Append(_random.Next(0,9).ToString());             }         }          if (set.Contains(builder.ToString()))         {             clashes++;             Console.WriteLine("clash: (" +n+ ")" +builder.ToString());         }          set.Add(builder.ToString());         _random.Next();         //Console.Write(builder.ToString());     }      Console.WriteLine("Clashes: " +clashes);     Console.ReadLine(); }   UPDATE:   from this question  I really asked two questions here so I was cheating. The answer I was after was rcar's, however Sklivvz's is also the answer to the 2nd part (an alternative). Is it possible to make a custom unique id generator in a database, or would it be client side (which would be 2 possible reads first)?  The general idea I was after was using Ids in databases or other stores that can be used by phone or printed material, not a giant 16 byte guid.  UPDATE 2: I put the formula for two mutually exclusive events above instead of 2 independent ones (as getting an 'a' the first time doesn't mean you can't get an 'a' the second time). Should've been P(A and B) = P(A) x P(B)
67177
I'm looking to create a simple short-lived reservation system, and I'd like to generate confirmation numbers that are   unique random-looking alphanumeric short-ish, at least much shorter than 32 character-long strings returned by sha1   I'm only looking to have ~500 reservations, so I don't imagine high likelyhood of collissions.  One idea I had is generate an sha1 hash based on a date-time stamp and username, then truncating it to its first 10 characters.  Would something like that be reliably unique enough for the purposes of processing ~500 reservations?
7553
I'd like to generate unique random numbers between 0 and 1000 that never repeat (i.e. 6 doesn't show up twice), but that doesn't resort to something like an O(N) search of previous values to do it. Is this possible?
52342
I need to randomly 'sort' a list of integers (0-1999) in the most efficient way possible.  Any ideas?  Currently, I am doing something like this:  bool[] bIndexSet = new bool[iItemCount];  for (int iCurIndex = 0; iCurIndex &lt; iItemCount; iCurIndex++) {     int iSwapIndex = random.Next(iItemCount);     if (!bIndexSet[iSwapIndex] &amp;&amp; iSwapIndex != iCurIndex)     {         int iTemp = values[iSwapIndex];         values[iSwapIndex] = values[iCurIndex];         values[iCurIndex] = values[iSwapIndex];         bIndexSet[iCurIndex] = true;         bIndexSet[iSwapIndex] = true;     } }
83434
I recently discovered this method for generating a 9 character password from the linux prompt in bash:  &lt; /dev/urandom tr -dc A-Za-z0-9_ | head -c9   What is &lt; doing?
97272
What is the most efficient way to get a random output with my commands? In Java there are tons of ways to do this, but a lot of them don’t seem to work for Bedrock Edition.
118742
I'm looking for a random dungeon generator for D&amp;D 3.5.  I'd like a generator that looks like , but specifically for D&amp;D, but also with a theme or groups option (Like crypt, or only undeads - only demons etc).  I've searched quite a bit for a good dungeon generator, but didn't find any especially good.  These are the 'top' ones I've found:    - Good, but no random room dressing / themes / encounter types;   - Quite nice, but too many details, bad maps and not D&amp;D specific;   - Almost perfect, but not D&amp;D specific;   - Good ideas, but not fully implemented yet (quite buggy in fact) , so half the features don't work.  I'd like to avoid generating anything manually, because of the concept of my game (everything is random, from character races/classes/alignment to adventure ideas).  Note: People say the  one is pretty much what I'm looking for, but the site is offline. If anyone knows another place where that is hosted or a similar generator, I'd be grateful.
40504
If you want a cryptographically strong random numbers in Java, you use SecureRandom. Unfortunately, SecureRandom can be very slow. If it uses /dev/random on Linux, it can block waiting for sufficient entropy to build up. How do you avoid the performance penalty?  Has anyone used  as a solution to this problem?  Can anybody confirm that this performance problem has been solved in JDK 6?
122428
Why the crazy password requirements? It a Q&amp;A site, and I have to conform to arbitrarily chosen password complexity criteria.  With a 22 random lowercase characters (entropy 119 bits), the  asks me to:    Just adding uppercase characters to the mix does not satisfy the requirements.  With 125 bits of entropy, It still asks me to:    Fortunately, doing either of these does satisfy the requirements. As long as there are enough unique characters.  The password a1ᓕ♵Ŀꁏꂯ (with a1 replacing Unicode characters to satisfy the numbers and letters requirement, reducing the level of entropy from 112 to 88 bits) still causes the generator to insist that the password:    Sadly, the famous  password doesn't fly, either:    I add entropy in my passwords in other ways than the Password1 (entropy approximately 0) mechanism suggested by these requirements, and prefer to use the Stack Exchange OpenID provider.