mirror of
				https://git.collinwebdesigns.de/oscar.krause/fastapi-dls.git
				synced 2025-11-04 06:30:21 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			541 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			541 B
		
	
	
	
		
			Python
		
	
	
	
	
	
try:
 | 
						|
    # Crypto | Cryptodome on Debian
 | 
						|
    from Crypto.PublicKey import RSA
 | 
						|
    from Crypto.PublicKey.RSA import RsaKey
 | 
						|
except ModuleNotFoundError:
 | 
						|
    from Cryptodome.PublicKey import RSA
 | 
						|
    from Cryptodome.PublicKey.RSA import RsaKey
 | 
						|
 | 
						|
 | 
						|
def load_file(filename) -> bytes:
 | 
						|
    with open(filename, 'rb') as file:
 | 
						|
        content = file.read()
 | 
						|
    return content
 | 
						|
 | 
						|
 | 
						|
def load_key(filename) -> RsaKey:
 | 
						|
    return RSA.import_key(extern_key=load_file(filename), passphrase=None)
 | 
						|
 | 
						|
 | 
						|
def generate_key() -> RsaKey:
 | 
						|
    return RSA.generate(bits=2048)
 |