Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

Can we perform wildcard search on encrypted columns in MySQL and Java

I'm working on a web application where customers' sensitive data like name, dob, etc need to encrypt and store in the database.

For this, I'm using crypto encryption in java to encrypt the given text and storing the encrypted value in the database.

The following is the piece of code to encrypt the text

import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Hex;

String key = "";// key to encrypt/decrypt    
String customerName = "customer name";

Key aesKey = generateMySQLAESKey(key,"UTF-8");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, aesKey);
byte[] encrypted = cipher.doFinal(customerName.getBytes("UTF-8"));
String encrtedName = new String(Hex.encodeHex(encrypted));
// storing this encrtedName as varchar in database

An exact search is done by passing with encrypted value in where clause while querying the data from the database

But how can we perform a wildcard search on encrypted columns?

I'm new to cryptography and encryption methods. Please let me know the best approach for this in Java or Mysql Database


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is more a remark than an answer but as a new member, I can only post answers.

Doing computations on encrypted data is linked to what is called "homomorphic encryption". This is a research topic but currently being implemented in the industry. I found this paper which seems to deal with your problem in a secure way: https://eprint.iacr.org/2020/931.pdf


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...