Skip to content

Instantly share code, notes, and snippets.

View VictorZZZZ's full-sized avatar
🎯
Focusing

Victor VictorZZZZ

🎯
Focusing
View GitHub Profile
@VictorZZZZ
VictorZZZZ / RSAEncryption.java
Created June 21, 2023 12:50
Encryption and Decryption example in Java
public class RSAEncryption {
public static void main(String[] args) throws NoSuchAlgorithmException, IOException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
// generateKeyPair();
final PublicKey publicKey = getPublicKeyFromFile("public.key");
final PrivateKey privateKey = getPrivateKeyFromFile("private.key");
String secret = "Some string";
String encodedMessage = encryptString(publicKey, secret);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test Web Socket</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.1/semantic.min.css"
rel="stylesheet">
</head>
<body>