Random Prime Generator/Modular Arithmetic

Astan Chee stanc at al.com.au
Sun Mar 5 17:02:40 CET 2006


Also I think the snippet code [p for p in range(2,N) if 0 not in 
[pow(w,p-1,p)==1 for w in [2, 3, 5, 7, 11] if p>w]] is probably nicer to 
generate a list of primes for up to N (instead of hard coded)
Aside from that looks nice.
Thanks

Tuvas wrote:

>Yep, you guessed correctly about the s2num function, I knew I should
>have put a bit more.. It just converts an ascii string to a number,
>however many numbers that are nessicary. I could indeed check for all
>primes below a certain number, however, it still seems to run quite
>fast, at least to a 400 digit number. It's not something I'm going to
>use a ton, so optimizing it might not be worth it much more than it is.
>Perhaps I'll try all primes at least up to 100, that wouldn't be too
>bad... Maybe I'll have to modify my old prime string to output the
>python command to check all of them, it's a bit of a pain the whole if
>0 in (n%2, n%3) stuff, and I can't think of a better way to do it
>without writing a new function to do so.
>I'm going to post the new code in just a minute, it's running quite
>nicely. I'm also posting my RSA function, which I believe should be
>secure enough. I'm uploading the code to them now, the HTML page'll be
>a few minutes...
>
>  
>



More information about the Python-list mailing list