我正在使用那个包
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
这是从table_1获取数据并在table_2中存储的函数
public void encrypDatabase() throws Exception {
String queGetData = "select ans, img from table_1";
String ans;
int img;
Cursor c = vDatabase.rawQuery(queGetData, new String[] {});
if (c != null) {
if (c.moveToFirst()) {
do { ans = getEncryptedString(c.getString(0));
img = c.getInt(1);
String queinsertData = "insert into table_2 values(" + ans + "', "+ img + ")";
eDatabase.execSQL(queinsertData);
} while (c.moveToNext());
}
}
}
这是加密功能100%
public String getEncryptedString(String s) throws Exception {
try {
kgen = KeyGenerator.getInstance("AES");
kgen.init(128);
skey = kgen.generateKey();
cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skey);
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return getString(cipher.doFinal(getBytes(s)));
}
// getString()它将byte []返回给String
的函数我无法在table_2中插入数据 如何解决这个问题
否则任何方法直接获取可以使用javax.cripto.cipher解密的加密数据库
听到字符串数据为'UTF-8',如“दीन-हीनअतिमलिनमति”
这是印地语文本