How to create masterKey after MasterKeys deprecated in Android

前端 未结 5 1215
南方客
南方客 2021-01-04 09:36

I am using the following code to store some information encrypted in my app.

    val masterKey = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)

    val s         


        
5条回答
  •  梦谈多话
    2021-01-04 10:14

    You can use it like this below

    //Creating MasterKey
                val masterKey = MasterKey.Builder(context)
                    .setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
                    .build()
    
                val fileToRead = "your_file_name.txt"
                val encryptedFile = EncryptedFile.Builder(context,
                    File(context.filesDir, fileToRead),
                    masterKey,
                    EncryptedFile.FileEncryptionScheme.AES256_GCM_HKDF_4KB
                ).build()
    

提交回复
热议问题