Changeset 1601:52e504c91cbc

Show
Ignore:
Timestamp:
11/04/08 09:27:49 (2 months ago)
Author:
Greg Von Kuster <greg@bx.psu.edu>
branch:
default
Message:

Apply James' faster_random patch from Nov 1.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/galaxy/web/security/__init__.py

    r1600 r1601  
    1111 
    1212if os.path.exists( "/dev/urandom" ): 
    13     log.debug("###using /dev/urandom....") 
    1413    # We have urandom, use it as the source of random data 
    1514    random_fd = os.open( "/dev/urandom", os.O_RDONLY ) 
     
    1817        # Normally we should get as much as we need 
    1918        if len( value ) == nbytes: 
    20             return value 
     19            return value.encode( "hex" ) 
    2120        # If we don't, keep reading (this is slow and should never happen) 
    2221        while len( value ) < nbytes: 
    2322            value += os.read( random_fd, nbytes - len( value ) ) 
    24         return value 
     23        return value.encode( "hex" ) 
    2524else: 
    2625    def get_random_bytes( nbytes ): 
     
    3029            random_pool.add_event() 
    3130        random_pool.stir() 
    32         return( str( number.getRandomNumber( nbits, random_pool.get_bytes ) ) ) 
     31        return str( number.getRandomNumber( nbits, random_pool.get_bytes ) ) 
     32 
    3333 
    3434class SecurityHelper( object ):