Steps to generate encrypted token
- Prepare an Object with following sample details.
{
"client_id": "d86149609e2972fe19403e22d014c7101a4c50f004ba0448e20362ebfbdb90cd42e4b5fd56d861189bd f7efda25f4e40", "client_secret": "2207c85437305733a3e6a536f33a248547e34eb876431fa091e8ce35e8475347e5754f0fcec1b0bf235f a8262676a20b0cd59f21a853eae68b34b0f32eeecbca", "epoch":"1723005493" //Current Time stamp } |
- Encrypt above object using the following public key.
a6T8tOCYiSzDTrcqPvCbJfy0wSQOVcfaevH0gtwCtoU=
|
Note: Client id, Client secret, pass_key, and public key have already been shared during onboarding. |
- Encryption can be done by the following programming languages as follows:
Encryption code in java:
package com.example.encryp_decryp; |
Encryption code in PHP:
function Encr($data) { $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
$dataBytes = str_split($data); $length = count($dataBytes); echo "length of payload: " . $length . "\n"; // if ($length % 16 != 0) { // $extendBlock = 16 - ($length % 16); // $payloadBytesBlock = array_merge($dataBytes, array_fill(0, $extendBlock, chr($extendBlock))); // } else { // $payloadBytesBlock = $dataBytes; // } $a = base64_decode("a6T8tOCYiSzDTrcqPvCbJfy0wSQOVcfaevH0gtwCtoU="); echo "length of key: " . strlen($a) . "\n"; $block = openssl_cipher_iv_length('aes-256-cbc'); $paddedData = PKCS7Padding($dataBytes, $block); $encrypted = openssl_encrypt($paddedData, 'aes-256-cbc', $a, OPENSSL_RAW_DATA, $iv); $result = $iv . $encrypted; $str = base64_encode($result); echo "result encrypted string: " . $str . "\n"; return $str; } function PKCS7Padding($data, $blockSize) { $padding = $blockSize - (count($data) % $blockSize); return array_merge($data, array_fill(0, $padding, chr($padding))); } ?>``` |
Notes: Encrypted token containing Client id, Client secret and epoch timestamp.[Client will get the encrypted data by encrypting client id, client secret ,epoch timestamp using a unique key] |