3. Extracting Dynamic & Static Keysby: saaiqSASLast Updated: 26/2/2025
In this section, we will walk you through the process of extracting both Dynamic Keys and Static Keys in String or int[] formats.
A usage sample of the ROSET Java API is available on GitHub. You can view it
here (ROSET Java API Usage Sample).
The API provides methods to extract keys by taking the key itself as a parameter. Once the key is successfully extracted into memory, these methods return an int ID. This unique ID is used to reference the extracted key in subsequent operations.
Extract Dynamic Keyint[] Dynamic Key
To extract a Dynamic Key in int[] format, use the extractDynamicKey(int[] key) method. The following code snippet demonstrates its usage:
int[] Dynamic_Key = // generated Dynamic Key
int Dynamic_Key_ID = SAS_ROSET.extractDynamicKey(Dynamic_Key);
// 'Dynamic_Key_ID' is the reference ID
Mixed String Dynamic Key
To extract a Dynamic Key in mixed String format, use the extractDynamicKeyString(String key, boolean base64) method. Below is a sample code snippet for this:
String Dynamic_Key = // generated Mixed String Dynamic Key
int Dynamic_Key_ID = SAS_ROSET.extractDynamicKeyString(Dynamic_Key, false);
// 'Dynamic_Key_ID' is the reference ID
Base64 String Dynamic Key
To extract a Dynamic Key in base64 String format, use the extractDynamicKeyString(String key, boolean base64) method, setting the base64 flag to true. Below is a sample code snippet for this:
String Dynamic_Key = // generated base64 String Dynamic Key
int Dynamic_Key_ID = SAS_ROSET.extractDynamicKeyString(Dynamic_Key, true);
// 'Dynamic_Key_ID' is the reference ID
Extract Static Keysint[] Static Keys
To extract Static Keys in int[] format, use the extractStaticKey(int[] key) method.
Since multiple Static Keys will be used, you should store the returned reference IDs in an int[].
These reference IDs will then be passed as parameters to the encryption and decryption methods, alongside the Dynamic Key ID and data.
Below is a sample code snippet demonstrating the process:
int[] Static_Key_1 = // generated Static Key
int[] Static_Key_2 = // generated Static Key
int[] Static_Key_3 = // generated Static Key
// Extraction
int Static_Key_ID_1 = SAS_ROSET.extractStaticKey(Static_Key_1);
int Static_Key_ID_2 = SAS_ROSET.extractStaticKey(Static_Key_2);
int Static_Key_ID_3 = SAS_ROSET.extractStaticKey(Static_Key_3);
// Reference ID array preparation
int[] ID_Array = {Static_Key_ID_1, Static_Key_ID_2, Static_Key_ID_3};
Base64 String Static Keys
To extract Static Keys in base64 String format, use the extractStaticKeyString(String key) method.
As with int[] Static Keys, you should store all the returned reference IDs in an int[].
These reference IDs will then be used in the encryption and decryption methods along with the Dynamic Key ID and data.
Below is a sample code snippet demonstrating the process:
String Static_Key_1 = // generated Static Key
String Static_Key_2 = // generated Static Key
String Static_Key_3 = // generated Static Key
// Extraction
int Static_Key_ID_1 = SAS_ROSET.extractStaticKeyString(Static_Key_1);
int Static_Key_ID_2 = SAS_ROSET.extractStaticKeyString(Static_Key_2);
int Static_Key_ID_3 = SAS_ROSET.extractStaticKeyString(Static_Key_3);
// Reference ID array preparation
int[] ID_Array = {Static_Key_ID_1, Static_Key_ID_2, Static_Key_ID_3};