How to encrypt and decrypt data
Encryption
API Encryption
All of the body data will need to be encrypted using AES-256. The response also will be in encrypted AES-256
Detail:
● Encryption Method: openssl_encrypt AES-256
● body: request body
● Method: aes-256-cbc
● Ciphertext: Provided by Innov8tif
● API_key: Provided by Innov8tif
● Encryption Formula:
data = openssl_encrypt(body, method, ciphertext+API_key, OPENSSL_RAW_DATA, ciphertext)
$body = 'your_body';
$method = 'AES-256-CBC';
$ciphertext = 'your_ciphertext';
$API_key = 'your_api_key';
$key = $ciphertext . $API_key;
$encryptedText = openssl_encrypt($body, $method, $key, OPENSSL_RAW_DATA, $ciphertext);
echo base64_encode($encryptedText);
?>import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
public class OpenSSLExample {
public static void main(String[] args) throws Exception {
String body = "your_body";
String method = "AES/CBC/PKCS5Padding";
String ciphertext = "your_ciphertext";
String API_key = "your_api_key";
SecretKeySpec keySpec = new SecretKeySpec((ciphertext + API_key).getBytes(StandardCharsets.UTF_8), "AES");
Cipher cipher = Cipher.getInstance(method);
cipher.init(Cipher.ENCRYPT_MODE, keySpec);
byte[] encryptedBytes = cipher.doFinal(body.getBytes(StandardCharsets.UTF_8));
String encryptedText = Base64.getEncoder().encodeToString(encryptedBytes);
System.out.println(encryptedText);
}
}
Decryption
Last updated