PromptBase
Close icon
Explore
Marketing & BusinessDown chevron icon
General
Home
Marketplace
Apps
Create
Hire
Login
Sell
Outlined heart icon
🤖 GPT

Prompts For Coders

Prompts For Coders gpt prompt mini thumbnail
4Heart icon
Favorites
29Eye icon
Views
TestedTick icon
TipsTick icon
🚀 Elevate Your Coding Skills with Our Prompts! 🧠💻 Dive into a world of coding challenges that will supercharge your problem-solving abilities! 🌟 Our unique prompts are the ultimate playground for coders of all levels. 🎯 Sharpen your logic, optimize your code, and unlock new horizons in programming. 🌐 Join us on a journey of growth and mastery, one prompt at a time! 🚀🔥
...more
$6.99
Get prompt
Add to cart icon
After purchasing, you will gain access to the prompt file, which you can use with ChatGPT or the app builder.
You'll receive 20 free generation credits with this purchase.
By purchasing this prompt, you agree to our terms of service.
Updated: 5 months ago

Prompt Details

Model
Chat - GPT-3.5 (gpt-3.5-turbo)
Token size
2,630 ($0.00530 / call)
Example input
Act as a coding assistant to write a function in Java to encrypt and decrypt data using RSA algorithm
Example output
The RSA algorithm is a widely used public key cryptography algorithm for encrypting and decrypting data. Here's an example of how you can write a Java program to encrypt and decrypt data using the RSA algorithm: import java.security.*; import javax.crypto.Cipher; public class RSAEncryptionExample { public static void main(String[] args) throws Exception { String plainText = "Hello, RSA Encryption!"; KeyPair keyPair = generateKeyPair(); byte[] encryptedData = encrypt(plainText, keyPair.getPublic()); System.out.println("Encrypted Data: " + bytesToHex(encryptedData)); String decryptedText = decrypt(encryptedData, keyPair.getPrivate()); System.out.println("Decrypted Text: " + decryptedText); } public static KeyPair generateKeyPair() throws Exception { KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(2048); // You can choose different key sizes return keyGen.generateKeyPair(); } public static byte[] encrypt(String data, PublicKey publicKey) throws Exception { Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.ENCRYPT_MODE, publicKey); return cipher.doFinal(data.getBytes()); } public static String decrypt(byte[] encryptedData, PrivateKey privateKey) throws Exception { Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.DECRYPT_MODE, privateKey); byte[] decryptedBytes = cipher.doFinal(encryptedData); return new String(decryptedBytes); } public static String bytesToHex(byte[] bytes) { StringBuilder result = new StringBuilder(); for (byte b : bytes) { result.append(String.format("%02X", b)); } return result.toString(); } }
Browse Marketplace