Android Question Implementation/support for Android Keystore system?

bjf

Member
Licensed User
Longtime User
Hello.

I saw this thread and i wonder if there has been an implementation of Keystore system?
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub Process_Globals
    Dim ks As KeyStore
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    ks.Initialize("Keystore")
    listAliases
    Dim alias As String = "DonManfred"
    Dim sk As Object = ks.createNewKeys(alias,2,"Dummyprincipal")
    Log(sk)

    'listAliases
    Dim strtoencrypt As String = "Test bla bla bla ;-)"
    Log($"String to Encrypt using Alias "${alias}" ${strtoencrypt}"$)
    ks.encryptString(alias,strtoencrypt)

End Sub
Sub KeyStore_Encrypted(encrypted() As Byte, iv() As Byte, base64 As String)
    Log($"KeyStore_Encrypted(${base64},${encrypted.Length},${iv.Length})"$)
    ' Note to save the iv array to later be able to Decrypt!
    Log($"Decrypt using the IV"$)
    Dim decrypted As String = ks.decryptString("DonManfred",base64,iv)
    Log($"Decrypted: ${decrypted}"$)
    
End Sub
 

Attachments

  • JoseJWTV0.02.zip
    257.9 KB · Views: 236
  • AndroidKeystoreEx.zip
    8.5 KB · Views: 235
Upvote 1
Top