Welcome to the RSA Encryption Framework! This framework provides a simple API for RSA encryption and decryption, allowing users to easily integrate RSA cryptography into their applications. The framework includes three main APIs: one to retrieve the public certificate, one to encrypt plaintext, and one to decrypt an encrypted Base64 string.
You can run the application and start swagger using http://localhost:5000/encryption/swagger-ui/index.html#/
To use the RSA Encryption Framework, follow these steps:
-
Clone the repository to your local machine:
git clone https://github.com/your-username/rsa-encryption-framework.git
-
Open the
application.properties
file in the project and configure the public and private keys:# RSA Keys Configuration app.encryption.publicKeys.key001=YOUR_PUBLIC_KEY_HERE app.encryption.privateKeys.key001==YOUR_PRIVATE_KEY_HERE
Replace
YOUR_PUBLIC_KEY_HERE
andYOUR_PRIVATE_KEY_HERE
with your actual public and private RSA keys. -
Build and run the application:
./mvnw spring-boot:run
The application will start, and you can access the APIs described below.
- Endpoint:
/v1/cert
- Method:
GET
- Description: Retrieves the public certificate used for RSA encryption.
- Example Request:
curl http://localhost:8080/v1/cert
- Endpoint:
/v1/encrypt
- Method:
POST
- Description: Encrypts plaintext and returns the encrypted Base64 string.
- Request Body:
{ "plaintext": "Hello, RSA!" }
- Example Request:
curl -X POST -H "Content-Type: application/json" -d '{"plaintext": "Hello, RSA!"}' http://localhost:8080/v1/encrypt
- Endpoint:
/v1/decrypt
- Method:
POST
- Description: Decrypts an encrypted Base64 string and returns the plaintext.
- Request Body:
{ "encryptedBase64String": "ENCRYPTED_BASE64_STRING_HERE" }
- Example Request:
curl -X POST -H "Content-Type: application/json" -d '{"encryptedBase64String": "ENCRYPTED_BASE64_STRING_HERE"}' http://localhost:8080/v1/decrypt
Make sure to handle and store your private key securely. Do not expose it in the source code or share it publicly.
Feel free to explore and integrate the RSA Encryption Framework into your projects! If you encounter any issues or have suggestions for improvement, please open an issue on the GitHub repository.
Happy encrypting!