CN112966278A - Method for Flutter to safely access SQLite in environment - Google Patents

Method for Flutter to safely access SQLite in environment Download PDF

Info

Publication number
CN112966278A
CN112966278A CN202110155323.8A CN202110155323A CN112966278A CN 112966278 A CN112966278 A CN 112966278A CN 202110155323 A CN202110155323 A CN 202110155323A CN 112966278 A CN112966278 A CN 112966278A
Authority
CN
China
Prior art keywords
flutter
database
encryption
project
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110155323.8A
Other languages
Chinese (zh)
Inventor
付树棣
张占永
胡学文
李永斌
胡金藏
王乾坤
罗海斌
王鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing tulayan Technology Co.,Ltd.
Original Assignee
Beijing Gaoyin Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Gaoyin Technology Co ltd filed Critical Beijing Gaoyin Technology Co ltd
Priority to CN202110155323.8A priority Critical patent/CN112966278A/en
Publication of CN112966278A publication Critical patent/CN112966278A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/174Redundancy elimination performed by the file system
    • G06F16/1744Redundancy elimination performed by the file system using compression, e.g. sparse files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Bioethics (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Storage Device Security (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to a method for Flutter environment to safely access SQLite. The method is applied to the Flutter project and comprises a process of creating a Flutter decryption decompression plug-in, a process of creating a Flutter database encryption plug-in, a database file decompression process, an encryption process and a database query process. The method provided by the invention can ensure the security of the database file in the Flutter project, and greatly improves the security of the data through the encryption of the compression packet, the encryption of the password and the encryption of the database file.

Description

Method for Flutter to safely access SQLite in environment
Technical Field
The invention relates to the technical field of data security, in particular to a method for Flutter to safely access SQLite in environment.
Background
Data security is very important to individuals, businesses, and society. How to ensure the security of database files and the convenience during query is a difficult problem to overcome in the development process. The native systems (Android and IOS) are provided with mature database file (db file) encryption and database (SQLite) reading schemes.
However, in the current Flutter environment, the Dart language does not support decryption and decompression of encrypted compressed files (zip files). The Dart language only supports encryption of tables created when a database is created, and does not support encryption of db files that have been generated. Therefore, no mature scheme is available for encrypting the database file (db file) and reading the encrypted database file.
If a technical scheme can be provided, how to quickly query the encrypted database file (db file) in the Flutter environment can be realized, and a query result is handed to a Flutter project for use is significant.
Disclosure of Invention
In order to achieve the above object, the present invention provides a method for Flutter environment to safely access SQLite, which is applied to a Flutter project and includes a process of creating a Flutter decryption decompression plug-in, a process of creating a Flutter database encryption plug-in, a database file decompression process, an encryption process, and a database query process:
the process of creating the Flutter decryption decompression plug-in includes:
step 1.2: creating a FLUTTER decryption decompression plug-in advance;
step 1.2: creating a communication channel between the Flutter project and Native;
the process for creating the Flutter database encryption plug-in comprises the following steps:
step 1.1: creating a Flutter encryption plug-in project;
step 1.2, a communication channel between the Flutter project and the Native is created;
step 1.3, packaging the database encryption method, the database opening method and the database query method into a plug-in for being called by a Flutter project;
the decompression process is applied to the Flutter project and comprises the following steps:
step 1: the Flutter project downloads the encrypted zip file to the local; the zip file is a compressed file of a database file with a password and is an original database compressed file;
step 2: the Flutter decompression plug-in uses the appointed Platform Channel to communicate with the Flutter project, decompresses the zip file, generates an unencrypted database file, and stores the decompressed file in a preset path;
the encryption process comprises the following steps:
step 1: reading an unencrypted database file by a Flutter project;
step 2: the Flutter project calls an encryption method of the Flutter database encryption plug-in; and encrypting the database file, and finishing encryption.
Further, creating a communication channel between the Flutter project and the Native specifically includes: creating a Platform Channel by using the BasicMessagechannel, and realizing communication between the Flutter project and Native by using the appointed Channel name.
Further, in the encryption process, in step 2, encrypting the database file specifically includes: and traversing and reading each data table in the database file, then creating a data table with a password, and writing the data in the original table into the encrypted data table.
Further, in the database encryption process, the method further comprises the step 3: and after the encryption is finished, deleting all the original database compressed files and the unencrypted files.
Further, in the database encryption process, the password encrypted by the database is related to the personal information of the user.
Further, the decompression password of the original database compressed file is packaged into the so file.
Further, the database query process specifically includes:
step 1: initiating a database query operation by the Flutter project, and transmitting the sql statement to the Flutter database encryption plug-in;
step 2: the Flutter project calls a query method in the Flutter database encryption plug-in, and the method executes query operation and accesses the encrypted database file;
and step 3: according to the field to be queried in the sql statement, the Flatter database encryption plug-in packages the query result into json and transmits the json back to the Flatter project;
further, the database query process further includes step 4: and the Flutter project receives json data, serializes the data, and then displays the data according to the service requirement.
Further, a flow of using the Android Studio or a terminal command line to create a Flutter decryption decompression plug-in and a Flutter database encryption plug-in.
The invention has the beneficial effects that:
the method provided by the invention can ensure the security of the database file in the Flutter project, and greatly improves the security of the data through the encryption of the compression packet, the encryption of the decompression password (the password is encrypted in so), and the encryption of the database file (db file).
Because the access cost of the Flutter project to the Flutter encryption plug-in is extremely low, only the original query operation needs to be changed into the execution of the query operation in the Flutter database encryption plug-in at the place where the sql query is executed, and compared with the original operation, the method does not need to be greatly changed, so that the development efficiency is greatly improved, and the development cost is reduced.
Drawings
FIG. 1 is a flow chart of the method of the present invention.
Detailed Description
The design concept of the invention is as follows: the invention realizes the communication between the Flutter project and Native by creating the Flutter decryption decompression plug-in and the Flutter database encryption plug-in, and can quickly query the database by changing the Flutter project with the minimum cost after encrypting the database file (db file) and display the query result.
The Flutter plug-in is also a Flutter project, but it can communicate with the Flutter project by using a well-agreed Platform Channel, so that the Flutter plug-in can use the native Flutter project to realize complex functions which are not supported by Flutter at present, and then communicate with the Flutter project through a data Channel to indirectly complete the product requirements of users. The method is described in detail below.
The invention provides a method for Flutter to safely access SQLite in environment. As shown in fig. 1, the method includes a process of creating a Flutter decryption decompression plug-in, a process of creating a Flutter database encryption plug-in, a database file decompression process, an encryption process, and a database query process. The method can be applied to the existing Flutter project.
The process of creating the Flutter decryption decompression plug-in comprises the following steps:
step 1.1: creating a Flatter decompression plug-in project;
the method specifically comprises the following steps: and creating a Flutter plug-in project by using the Android Studio or the terminal command line. The Android end can select Java or kotlin language, and the IOS end can select OC or Swift language.
Step 1.2, a communication channel between the Flutter project and the Native is created;
the method specifically comprises the following steps: platform Channel is created using the BasicMessageChannel, using the agreed Channel name to facilitate communication with the Flutter project. The Channel name here can be any value as long as it is ensured that the Flutter side and the Flutter plug-in side are consistent.
The process for creating the Flutter database encryption plug-in comprises the following steps:
step 1.1: creating a Flutter encryption plug-in project;
step 1.2, a communication channel between the Flutter project and the Native is created;
the method specifically comprises the following steps: creating a Platform Channel by using the BasicMessageChannel, and facilitating communication with a Flutter project by using an agreed Channel name;
an encryption database, a database opening method and a database query method are embedded in the encryption plug-in of the Flutter database. The database encryption method is characterized in that the database is encrypted by using Sqlcipher, and a database which can only be accessed by using a password through a program code is created; opening the Database method, namely calling the openOrCreateDatabase method by using the Database provided in Sqlcipher; the database query method takes sql statements as parameters, uses a rawQuery method in Sqlcipher, converts queried cursor results into json serving as return values to be used by the Flutter terminal, and writes specific sql statements to the Flutter service terminal.
The database file decompression process comprises the following steps:
step 1: the Flutter project downloads the encrypted zip file to the local; the zip file is a compressed file of a database file with a password, and is called as an original database compressed file in the application.
The decompression password of the zip file is packaged into the so file, so that the first layer of security of data is guaranteed.
Step 2: the Flutter decompression plug-in communicates with the Flutter project by using the agreed Platform Channel, decompresses the original database compressed file by using zip4J, generates an unencrypted database file, and stores the decompressed file in a predetermined path.
The encryption process comprises the following steps:
step 1: reading an unencrypted database compressed file by a Flutter item;
the unencrypted database compressed file is an unencrypted database file (db file) obtained by decompression of the flute decompression plug-in.
Step 2, calling an encryption method of the Flutter database encryption plug-in by the Flutter project; and encrypting the database file, and finishing encryption.
Encrypting the database file specifically comprises: traversing and reading each data table in the database file, creating a data table with a password, and writing the data in the original data table into the encrypted data table (here, the one-to-one correspondence relationship between the table names and the field names of the encrypted data table can be adopted for developing efficiency, and renaming is not needed).
Further, in order to further enhance the security of the data, in the encryption process, a step 3 of deleting all the original database compressed files and unencrypted files is also included.
The original compressed file and the unencrypted database file (db file) can be deleted no matter the encryption fails or the encryption succeeds, so that the database file (db file) which exists locally can only be the encrypted database file, and no unencrypted information exists locally, and the second-layer security of the data is guaranteed.
Furthermore, in the database encryption process, the password encrypted by the database is related to the personal information of the user (for example, the user id is used to splice the city id to which the user belongs as the password), and is not a fixed password, so that the third layer security of the data is ensured.
The database query process comprises the following steps:
step 1: initiating a database query operation by the Flutter project, transmitting the sql statement to the Flutter database encryption plug-in, calling a query method in the Flutter database encryption plug-in, and executing the query operation;
step 2: the Flatter database encryption plug-in receives the sql statement, opens the encrypted database file data, and executes database query operation according to the field to be queried in the sql statement;
and step 3: encapsulating the query result into json by the encryption plug-in of the Flutter database, and transmitting the json back to the Flutter project;
because the encryption database, the database opening method and the database query method are packaged in the encryption plug-in of the Flutter database, when the database query operation is executed, an additional method does not need to be executed, and only the method for querying the database needs to be called under the condition that the database is ensured to be opened, and the sql statement is transmitted into the method. Therefore, the cost of accessing the Flutter project is extremely low, and compared with the method for querying the unencrypted database file, the method does not need to be changed greatly.
Further, the method also comprises the step 4: and the Flutter project receives json data, serializes the data, and then performs UI display according to the service requirement.
The operation of querying the unencrypted database file in the original Flutter project hardly has any difference in the step. The json data is just needed to be subjected to json decode, and the data is converted into a dynamic type without any change in the using process. Therefore, after the Flutter project is accessed to the Flutter encryption plug-in, the database file is encrypted, and the subsequent operation of querying the database is simple and convenient.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (9)

1. The method for safe access to SQLite by the Flutter environment is characterized by being applied to a Flutter project and comprising a process of creating a Flutter decryption decompression plug-in, a process of creating a Flutter database encryption plug-in, a database file decompression process, an encryption process and a database query process:
the process of creating the Flutter decryption decompression plug-in includes:
step 1.2: creating a FLUTTER decryption decompression plug-in advance;
step 1.2: creating a communication channel between the Flutter project and Native;
the process for creating the Flutter database encryption plug-in comprises the following steps:
step 1.1: creating a Flutter encryption plug-in project;
step 1.2, a communication channel between the Flutter project and the Native is created;
step 1.3, packaging the database encryption method, the database opening method and the database query method into a plug-in for being called by a Flutter project;
the decompression process is applied to the Flutter project and comprises the following steps:
step 1: the Flutter project downloads the encrypted zip file to the local; the zip file is a compressed file of a database file with a password and is an original database compressed file;
step 2: the Flutter decompression plug-in communicates with the Flutter project by using the appointed platformChanel, decompresses the zip file to generate an unencrypted database file, and stores the decompressed file in a preset path;
the encryption process comprises the following steps:
step 1: reading an unencrypted database file by a Flutter project;
step 2: the Flutter project calls an encryption method of the Flutter database encryption plug-in; and encrypting the database file, and finishing encryption.
2. The method for Flutter environment secure access SQLite according to claim 1, wherein creating a communication channel between the Flutter project and Native specifically comprises: and (3) creating platformChannel by using the BasicMessageChannel, and realizing communication between the Flutter project and Native by using the appointed Channel name.
3. The Flutter environment security access SQLite method of claim 1, wherein in the encryption process, in step 2, encrypting the database file specifically comprises: and traversing and reading each data table in the database file, then creating a data table with a password, and writing the data in the original table into the encrypted data table.
4. The Flutter environment secure access SQLite method according to claim 1 or 3, further comprising step 3: and after the encryption is finished, deleting all the original database compressed files and the unencrypted files.
5. The Flutter environment secure access SQLite method of claim 1, wherein in the database encryption process, the database encrypted password is related to the user's personal information.
6. The Flutter environment secure access SQLite method of claim 1, wherein a decompressed password of an original database compressed file is encapsulated into a so file.
7. The Flutter environment security access SQLite method of claim 1, wherein the database query process is specifically:
step 1, initiating a database query operation by a Flutter project, and transmitting an sql statement to an encryption plug-in of the Flutter database;
step 2, calling a query method in the encryption plug-in of the Flutter database by the Flutter project, executing query operation by the method, and accessing the encrypted database file;
and step 3: and according to the field to be queried in the sql statement, encapsulating the query result into json by the Flatter database encryption plug-in, and transmitting the json back to the Flatter project.
8. The Flutter environment secure access SQLite method of claim 7, wherein the database query procedure further comprises step 4: and the Flutter project receives json data, serializes the data, and then displays the data according to the service requirement.
9. The method for securely accessing SQLite in Flutter environment according to claim 1, wherein the flow of Flutter decrypting and decompressing plug-ins, Flutter database encrypting plug-ins, is created using android studio or terminal command line.
CN202110155323.8A 2021-02-04 2021-02-04 Method for Flutter to safely access SQLite in environment Pending CN112966278A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110155323.8A CN112966278A (en) 2021-02-04 2021-02-04 Method for Flutter to safely access SQLite in environment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110155323.8A CN112966278A (en) 2021-02-04 2021-02-04 Method for Flutter to safely access SQLite in environment

Publications (1)

Publication Number Publication Date
CN112966278A true CN112966278A (en) 2021-06-15

Family

ID=76273781

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110155323.8A Pending CN112966278A (en) 2021-02-04 2021-02-04 Method for Flutter to safely access SQLite in environment

Country Status (1)

Country Link
CN (1) CN112966278A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100250926A1 (en) * 2007-08-28 2010-09-30 Joon Tae Ji Method of digital rights management about a compressed file
CN104679816A (en) * 2014-12-17 2015-06-03 北京可思云海科技有限公司 Application method of SQLITE database in embedded system
CN109033359A (en) * 2018-07-26 2018-12-18 北京天地和兴科技有限公司 A kind of method of multi-process secure access sqlite
CN109101837A (en) * 2018-08-10 2018-12-28 郑州云海信息技术有限公司 A kind of date storage method and device
CN111008009A (en) * 2019-11-05 2020-04-14 贝壳技术有限公司 Service componentization method and system based on Flutter
CN111182019A (en) * 2019-08-08 2020-05-19 腾讯科技(深圳)有限公司 Cross-platform communication method and device and electronic equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100250926A1 (en) * 2007-08-28 2010-09-30 Joon Tae Ji Method of digital rights management about a compressed file
CN104679816A (en) * 2014-12-17 2015-06-03 北京可思云海科技有限公司 Application method of SQLITE database in embedded system
CN109033359A (en) * 2018-07-26 2018-12-18 北京天地和兴科技有限公司 A kind of method of multi-process secure access sqlite
CN109101837A (en) * 2018-08-10 2018-12-28 郑州云海信息技术有限公司 A kind of date storage method and device
CN111182019A (en) * 2019-08-08 2020-05-19 腾讯科技(深圳)有限公司 Cross-platform communication method and device and electronic equipment
CN111008009A (en) * 2019-11-05 2020-04-14 贝壳技术有限公司 Service componentization method and system based on Flutter

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
江炳城;何倩;陈亦婷;刘鹏;: "面向云数据库的属性基加密和查询转换中间件", 计算机应用, no. 08 *

Similar Documents

Publication Publication Date Title
US11120018B2 (en) Spark query method and system supporting trusted computing
US11100244B2 (en) File packaging and unpackaging methods, apparatuses, and network devices
US20020062439A1 (en) Digital signaturing method and system for packaging specialized native files for open network transport and for burning onto cd-rom
US9152813B2 (en) Transparent real-time access to encrypted non-relational data
WO2020119379A1 (en) Blockchain smart contract-based coding and decoding method and system
CN109992563A (en) A kind of service scripts storage method and device based on block chain
US8826017B2 (en) Optimizing web landing page link access times through preliminary functions during page deployment
CN112491832B (en) File transmission method and device
CN111209001A (en) Method, system, equipment and medium for batch generation of APKs of android channels
WO2012164427A1 (en) Protecting a control vector in a cryptographic system
CN115509582A (en) Application program issuing method, device, equipment and storage medium
CN113836498A (en) Webpage source code obfuscation method and device, electronic device and storage medium
CN111680477A (en) Method and device for exporting spreadsheet file, computer equipment and storage medium
CN104978537A (en) Document access authority configuration method and device
CN106843818A (en) A kind of business model generation method and device
CN108737353A (en) A kind of data ciphering method and device based on data analysis system
CN112966278A (en) Method for Flutter to safely access SQLite in environment
CN107247622A (en) A kind of collocation method and device for opening application more
CN106775843A (en) The bytecode-optimized methods of dalvik based on internal memory loading
CN104504324B (en) Mobile solution certification reinforcement means and system
WO2017063323A1 (en) Method for implementing cloud locking of sensitive data based on reconstruction technology
CN116136844A (en) Entity identification information generation method, device, medium and electronic equipment
US20180019977A1 (en) Multi-layered data security
Dai et al. A cloud trust authority framework for mobile enterprise information system
CN109697069A (en) A kind of packaging method and terminal of H5 application

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20210825

Address after: 100000 1025, floor 1, No. 1, Kaifa Road, Shangdi Information Industry base, Haidian District, Beijing

Applicant after: Beijing tulayan Technology Co.,Ltd.

Address before: 100089 08a01, block D, 8 / F, No. a 28, information road, Haidian District, Beijing

Applicant before: Beijing Gaoyin Technology Co.,Ltd.

TA01 Transfer of patent application right
AD01 Patent right deemed abandoned

Effective date of abandoning: 20240607