Please post a small example with the code that inserts the data and the code that extracts it.
kvs.PutEncrypted("data_db", server_txt.Text, "DBserver")
kvs.PutEncrypted("data_db", port_txt.Text, "DBport")
kvs.PutEncrypted("data_db", DBname_txt.Text, "DBname")
kvs.PutEncrypted("data_db", user_txt.Text, "DBuser")
kvs.PutEncrypted("data_db", pass_txt.Text, "DBpass")
If kvs.ContainsKey("data_db") Then
mySQLConfig.MYSQLIP = kvs.GetEncrypted("data_db", "DBserver")
mySQLConfig.MYSQLPORT = kvs.GetEncrypted("data_db", "DBport")
mySQLConfig.MYSQLDBNAME = kvs.GetEncrypted("data_db", "DBname")
mySQLConfig.MYSQLUSER = kvs.GetEncrypted("data_db", "DBuser")
mySQLConfig.MYSQLIP = kvs.GetEncrypted("data_db", "DBpass")
End If
Dim MYSQLIP = "192.168.XX.XXX" As String
Dim MYSQLDBNAME = "name" As String
Dim MYSQLPORT = "1234" As String
Dim MYSQLUSER = "user" As String
Dim MySQLPASS = "password1" As String
We cannot help you with this code. You need to create a small example and upload it.
Error occurred on line: 49 (Main)
javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
at com.android.org.conscrypt.NativeCrypto.EVP_CipherFinal_ex(Native Method)
at com.android.org.conscrypt.OpenSSLCipher$EVP_CIPHER.doFinalInternal(OpenSSLCipher.java:568)
at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:350)
at javax.crypto.Cipher.doFinal(Cipher.java:2056)
at anywheresoftware.b4a.object.B4XEncryption.Decrypt(B4XEncryption.java:47)
at b4a.example3.keyvaluestore._getencrypted(keyvaluestore.java:139)
at b4a.example.main._loadsaves(main.java:412)
at b4a.example.main._activity_create(main.java:393)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
it does.It must log "data written".
kvs.PutEncrypted("data_db", "192.168.1.31", "DBserver")
kvs.PutEncrypted("data_db", 1234, "DBport")
kvs.PutEncrypted("data_db", "kvs_test", "DBname")
kvs.PutEncrypted("data_db", "admin", "DBuser")
kvs.PutEncrypted("data_db", "pw1234", "DBpass")
Log(kvs.GetEncrypted("data_db", "DBserver"))
Sub loadSaves
If kvs.ContainsKey("data_db") Then
Log("exist data")
Log(kvs.GetEncrypted("data_db_server", "DBserver"))
Log(kvs.GetEncrypted("data_db_port", "DBport"))
Log(kvs.GetEncrypted("data_db_name", "DBname"))
Log(kvs.GetEncrypted("data_db_user", "DBuser"))
Log(kvs.GetEncrypted("data_db_pass", "DBpass"))
End If
End Sub
Sub writeSaves
kvs.PutEncrypted("data_db_server", "192.168.1.31", "DBserver")
kvs.PutEncrypted("data_db_port", 1234, "DBport")
kvs.PutEncrypted("data_db_name", "kvs_test", "DBname")
kvs.PutEncrypted("data_db_user", "admin", "DBuser")
kvs.PutEncrypted("data_db_pass", "pw1234", "DBpass")
Log("data written")
End Sub
Sub loadSaves
If kvs.ContainsKey("data_db") Then
Log("exist data")
Dim m As Map = kvs.GetEncrypted("data_db", "SecurityPW")
Log(m)
End If
End Sub
Sub writeSaves
Dim m As Map = CreateMap("Server": "192.168.1.31", "Port": 1234,"Name":"kvs_test","User":"admin","Passord":"pw1234")
kvs.PutEncrypted("data_db", m, "SecurityPW")
Log("data written")
End Sub
Ohh. Thank you very much Manfred.Only ONE key is used. So at the end the key data_db contains the encrypted pw1234.
When you start your app
will read the key data_db with the passwort for the Server. BUT the Data inside the key is the password! But you are using the server password to decrypt. It is the WRONG password to decrypt the pw1234!B4X:Log(kvs.GetEncrypted("data_db", "DBserver"))
yes.password is the string used to encrypt the value to store?
No. KVS is using ONE Sqlite-Database file which name you set in initializationand the key parameter was the name of the encrypted file
kvs.Initialize(File.DirInternal, "internal_data")
Ok, thank you again.yes.
No. KVS is using ONE Sqlite-Database file which name you set in initialization
the file internal_data is the database file where ALL is saved in or loaded from.B4X:kvs.Initialize(File.DirInternal, "internal_data")