Deterministic and non uniform long string generation from seed
Question: I had this weird idea for an encryption that I wanted to try out, it may be
bad, and it may have done before, but I'm just doing it for fun. The short
version of the question is: Is it possible to generate a long, deterministic
and non-uniformly distributed string/sequence of numbers from a small seed?

Long(er) version: I was thinking to encrypt a text by changing encoding. The
new encoding would be generated via Huffman algorithm. To work well, the
Huffman algorithm would need a fairly long text with non uniform distribution.
Then characters can have different bit-lengths which would be the primary
strength of this encryption. The problem is that its impractical to enter
in/remember a long text each time you want to decrypt the text. So I was
wondering if it was possible to generate a text from password seed?

It doesn't matter what the text is, as long as it has non uniform distribution
of characters and that the exact same sequence can be recreated each time you
give it the same seed. Preferably, are there any functions/extensions in
Python that can do this?

EDIT: To expand on the "strength" of varying bit length: if I have a string
"test", ASCII values 116, 101, 115, 116, which gives bit values of 1110100
1100101 1110011 1110100

Then, say my Huffman algorithm generates encoding like t = 101 e = 1100111 s =
10001

The final string is 101 1100111 10001 101, if we encode this back to ASCII, we
get 1011100 1111000 1101000, which is 3 entirely different characters, its
"\xh". Obviously its impossible to perform any kind of frequency analysis or
something like that on this.


Answer: This is a solution based on `random` module, which will generate the same
sequence if given the same seed.

    
    
    import random
    from string import ascii_lowercase
    from collections import Counter
    
    seed_value = 3334
    string_length = 50
    random.seed(seed_value)
    seq = [(x,random.randint(1,10)) for x in ascii_lowercase]
    weighted_choice = lambda s : random.choice(sum(([v]*wt for v,wt in s),[]))
    random_list = [weighted_choice(seq) for x in range(string_length)]
    print("".join(random_list))
    print("Test non uniform distribution...")
    print(Counter(random_list))
    

