зеркало из
				https://github.com/iharh/notes.git
				synced 2025-10-31 13:46:08 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			13 строки
		
	
	
		
			464 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			13 строки
		
	
	
		
			464 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| // load pub-key from file
 | |
| FileInputStream fis = new FileInputStream("public.pem");
 | |
| BufferedInputStream bis = new BufferedInputStream(fis);
 | |
| DataInputStream dis = new DataInputStream(bis);
 | |
| byte[] keyBytes = new byte[dis.available()];
 | |
| dis.readFully(keyBytes);
 | |
| dis.close();
 | |
| 
 | |
| // transform bytes to PublicKey object
 | |
| X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);
 | |
| KeyFactory kf = KeyFactory.getInstance("RSA");
 | |
| PublicKey publicKey = kf.generatePublic(spec);
 | 
