To encrypt data, on the server side, you need to perform relevant configurations to generate keys; on the client side, complete corresponding configurations according to different operating platforms.
Server
Log on to the mPaaS console. In the left-side navigation pane, click Mobile Gateway Service.
Click the Manage gateway tab. On the Manage gateway tab, click the Function switch tab.
Switch the status of Data encryption to On.
In the Configure encryption algorithm dialog box that appears, configure the following settings:
Encryption algorithm: ECC, RSA, and SM2 are supported.
Key pair:
If the encryption algorithm is set to ECC or SSM, enter the private key content.
If the encryption algorithm is RSA, enter the public and private keys respectively.
For more information about how to generate a key for an encryption algorithm, see How to generate a key.
Client configuration
Android configuration
Create a mpaas_netconfig.properties file in the assets directory to store network-related global configurations.

Crypt: Indicates whether to use self-encryption,trueindicates to use,falseindicates to disable self-encryption function.RSA/ECC/SM2: Indicates the asymmetric encryption algorithm to use, whose value can only be filled withRSAorECCorSM2.PubKey: Indicates the public key of the selected asymmetric encryption algorithm.NoteSince the
valuevalues of thepropertiesfiles in Android need to be on the same line, you need to be aware of using line breaks\nconvert thePubkeyto one line when populating the public key.GWWhiteList: The gateway that needs to be encrypted is the gateway address of the current environment (therpcGWfield in the configuration file obtained from the mPaaS console). Without this key, all requests will not be encrypted.
iOS configuration
The iOS encryption configuration is read from the info.plist, as shown in the following figure: 
mPaaSCrypt: The main key and value of the encryption configuration areDictionarytypes, which contain relevant information required for client encryption.Crypt: specifies whether to encrypt data. The value isBooleantype.YESindicates that data is encrypted.NOindicates that data is not encrypted.When Crypt is set to
NO, RPC does not encrypt andRSA/ECC/SM2andPubKeysettings are ignored.When Crypt is set to
YES,RSA/ECC/SM2andPubKeymust be set and cannot be empty string, otherwise it will be asserted in Debug and the program will exit directly.
GWWhiteList: The gateway that needs to be encrypted is the gateway address of the current environment (therpcGWfield in the configuration file obtained from the mPaaS console). Without this key, all requests will not be encrypted.RSA/ECC/SM2: asymmetric encryption algorithm selection. The value is of theStringtype and can only beRSAorECCorSM2. TheRSA/ECC/SM2andPubKeysettings must correspond to each other.Select a
RSAalgorithm and enterRSApublic key in PubKey.Select a
ECCalgorithm and enterECCpublic key in PubKey.Select a
SM2algorithm and enterSM2public key in PubKey.
PubKey: Asymmetric encryption the public key. The value isStringtype, consistent with the asymmetric encryption algorithm chosen.The PubKey format must include the
-----BEGIN PUBLIC KEY-----and-----END PUBLIC KEY-----. The format is as follows:-----BEGIN PUBLIC KEY----- ************************ ************************ ************************ ************************ -----END PUBLIC KEY-----