Add Two Numbers
A minimal Visual Studio Code extension that demonstrates command creation in the VS Code API.
Command available in the Command Palette:
Add Two Numbers
The extension prompts for two numbers and displays the sum.
Java Cryptography Reference
Below are example implementations of AES and DES encryption in Java.
AES Encryption Example
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.util.Base64;
public class AESExample {
public static void main(String[] args) throws Exception {
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
keyGen.init(128);
SecretKey key = keyGen.generateKey();
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, key);
String text = "HelloWorld";
byte[] encrypted = cipher.doFinal(text.getBytes());
System.out.println("Encrypted: " +
Base64.getEncoder().encodeToString(encrypted));
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] decrypted = cipher.doFinal(encrypted);
System.out.println("Decrypted: " + new String(decrypted));
}
}
DES Encryption Example
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.util.Base64;
public class DESExample {
public static void main(String[] args) throws Exception {
KeyGenerator keyGen = KeyGenerator.getInstance("DES");
keyGen.init(56);
SecretKey key = keyGen.generateKey();
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE, key);
String message = "HelloWorld";
byte[] encrypted = cipher.doFinal(message.getBytes());
System.out.println("Encrypted: " +
Base64.getEncoder().encodeToString(encrypted));
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] decrypted = cipher.doFinal(encrypted);
System.out.println("Decrypted: " + new String(decrypted));
}
}
Installing the Extension
Download .vsix and install from:
Extensions → Install from VSIX