Skip to content

Instantly share code, notes, and snippets.

@BDOMDev
Last active June 26, 2019 08:59
Show Gist options
  • Select an option

  • Save BDOMDev/936f9bd4fd39f950d7fd7de119a648e0 to your computer and use it in GitHub Desktop.

Select an option

Save BDOMDev/936f9bd4fd39f950d7fd7de119a648e0 to your computer and use it in GitHub Desktop.

Revisions

  1. BDOMDev revised this gist Jun 26, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion DownloadActivity.kt
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    fun encryptDownloadedFile() {
    try {
    val filePath = filesDir.absolutePath + "/file.pdf"
    val filePath = filesDir.absolutePath + "/filename"
    val fileData = readFile(filePath)

    //get secret key
  2. BDOMDev created this gist Jun 26, 2019.
    16 changes: 16 additions & 0 deletions DownloadActivity.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    fun encryptDownloadedFile() {
    try {
    val filePath = filesDir.absolutePath + "/file.pdf"
    val fileData = readFile(filePath)

    //get secret key
    val secretKey = getSecretKey(sharedPref)
    //encrypt file
    val encodedData = encrypt(secretKey, fileData)

    saveFile(encodedData, filePath)

    } catch (e: Exception) {
    Log.d(mTag, e.message)
    }
    }