Generate a byte sequence with fixed size from a string
<p>I want to create a byte sequence with a fixed length out of a string which has a variable length. What is the best way to archive this. All bytes should be as different as possible.</p>

<h3>The code is used for research for myself, nothing productive.</h3>

<p>This has been my first approach for the generation of the bytes:</p>

<pre><code>static byte[] GenerateBytes(string password, Int32 strength)
{
    Byte[] result = new byte[strength];
    Byte[] pwBytes = Encoding.ASCII.GetBytes(password);
    Int32 prime = GetLowerPrime(pwBytes.Length);

    // Offset count to avoid values
    Int32 count = prime;
    Int32 sum = 0;
    for (int i = 0; i &lt; result.Length; i++) {
        sum += (result[i] = pwBytes[(count++ % pwBytes.Length)]);
    }

    count += prime;
    Int32 pcount = prime;
    for (int i = 0; i &lt; result.Length * 7; i++) {
        result[(i % result.Length)] ^= (Byte)(pwBytes[(count++ % pwBytes.Length)] ^ ((pcount += pwBytes[(count % pwBytes.Length)]) % 255));
    }

    return result;
}
</code></pre>

<p>And generated some samples with 256 / 128 / 64 generated bytes and counted the unique bytes:</p>

<pre><code>Password "Short":                170  103  60
Password "LongerX":              173  101  55
Password "Really Long":          169  100  57
Password "Unbelivable Safe!0§$": 162  101  56
Password "MCV":                  119  113  61
Password "AAA":                  50   51   50
Password "BBB":                  67   67   52
Password "AAAAAA":               48   48   48
</code></pre>

<p>I tried to change the prime selector a bit this improves the generation with short keys but has partly a impact on long ones. I also tracked some statistics of the bytes. Generated and each byte value is used between 9 and 30 times.</p>

<h3>What do you think about the results? How can i improve the generation of the bytes?</h3>
