mirror of
				https://github.com/home-assistant/core.git
				synced 2025-11-04 00:19:31 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			14 lines
		
	
	
		
			269 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			14 lines
		
	
	
		
			269 B
		
	
	
	
		
			Python
		
	
	
	
	
	
"""Auth utils."""
 | 
						|
import binascii
 | 
						|
import os
 | 
						|
 | 
						|
 | 
						|
def generate_secret(entropy: int = 32) -> str:
 | 
						|
    """Generate a secret.
 | 
						|
 | 
						|
    Backport of secrets.token_hex from Python 3.6
 | 
						|
 | 
						|
    Event loop friendly.
 | 
						|
    """
 | 
						|
    return binascii.hexlify(os.urandom(entropy)).decode('ascii')
 |