Tuvas wrote:
> Okay, I'm working on devoloping a simple, cryptographically secure
> number, from a range of numbers (As one might do for finding large
> numbers, to test if they are prime). My function looks like this:
> 
> def cran_rand(min,max):
>     if(min>max):
>         x=max
>         max=min
>         min=x
>     range=round(log(max-min)/log(256))
>     if range==0:
>         range=1
>     num=max+1
>     while(num>max):
>         num=min+s2num(urandom(range))
>     return num
> 
> Any comments on this? I think it should hold up to a test, it seems to
> work alright.

Have to disagree. Try:

   for _ in range(100):
       print cran_rand(0, 500)

How many numbers greater than 255 do you get?


I have more comments, but that's the biggest issue.


-- 
--Bryan
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to