Huawei Developers
Published in

Huawei Developers

Expert: Saving Sensitive Data Securely using Huawei Data Security Engine in Android

Introduction

Huawei Data Security Engine provides feature for secure asset storage and provides file protection as well. This article explains about Secure Asset Storage. It can be used for storing data of 64 byte or less. We can store data like username-password, credit card information, app token etc. All those data can be modified and deleted using Secure Asset Storage methods. Internally it uses Encryption and Decryption algorithms. So we do not need to worry about data security.

Requirements

  1. Android Studio V3.0.1 or later.
  2. Huawei Device with EMUI 10.0 or later.

Let us start with the project configuration part:

Step 1: Register as a Huawei Developer.

Step 2: Create new Android Studio project.

Step 3: Download and extract Huawei-datasecurity-android-demo.zip from Data Security Engine Sample Code.

Step 4: Copy securitykit-1.0.1.aar file from extracted path \DataSecurityDemo\app\libs and place inside your project libs folder.

Step 5: Add the securitykit-1.0.1.aar file to app-level build.gradle file.

Step 6: Sync the project.

Let us start with the implementation part:

Step 1: Create activity_main.xml for Insert, Update, Delete and Get Record buttons.

Step 2: Implement Click listener for buttons inside MainActivity.java.

Insert Record Implementation

Step 1: Create insert.xml layout for inserting data.

Step 2: Get the HwAssetManager instance for inserting the data.

Step 3: Create InsertActivity.java and use assetInsert() method for inserting the data.

Get Record Implementation

Step 1: Create get_record.xml.

Step 2: Create GetRecordActivity.java and use assetSelect() method for getting all records.

Update Record Implementation

Step 1: Create update_record.xml.

Step 2: Create model class for Record.

Step 3: Create AppUtils.java for getting all record.

Step 4: Create UpdateRecordActivity.java and use assetUpdate() method for updating the data.

Delete Record Implementation

Step 1: Create delete_record.xml.

Step 2: Create DeleteRecordActivity.java and use assetDelete() method to delete the records.

Now Implementation part done.

Result

Tips and Tricks

1. Set minSdkVersion to 28 in app-level build.gradle file.

2. Get BUNDLE_ASSETHANDLE tag data from Get Records feature and use the same tag to delete and update record.

3. Do not forget to add BUNDLE_APPTAG while inserting data.

Conclusion

In this article, we have learnt about saving our sensitive data securely using Huawei Data Security Engine. We can also delete, update and get all data using this feature. It also reduces our work for saving data in mobile application securely after using so many algorithms and encryption techniques.

Thanks for reading! If you enjoyed this story, please provide Likes and Comments.

Reference

Data Security Engine Implementation

Thanks for reading! If you enjoyed this story, please provide Likes and Comments.

Data Security Engine Implementation

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store