Fix password encoding
This commit is contained in:
parent
9d1bfd606f
commit
e83cfc9794
@ -9,10 +9,11 @@ object WidgetUtil {
|
|||||||
fun encodeEditTextContent(editText: EditText): ByteArray {
|
fun encodeEditTextContent(editText: EditText): ByteArray {
|
||||||
val charArray = CharArray(editText.text.length)
|
val charArray = CharArray(editText.text.length)
|
||||||
editText.text.getChars(0, editText.text.length, charArray, 0)
|
editText.text.getChars(0, editText.text.length, charArray, 0)
|
||||||
val byteArray = StandardCharsets.UTF_8.encode(
|
val byteBuffer = StandardCharsets.UTF_8.encode(CharBuffer.wrap(charArray))
|
||||||
CharBuffer.wrap(charArray)
|
|
||||||
).array()
|
|
||||||
Arrays.fill(charArray, Char.MIN_VALUE)
|
Arrays.fill(charArray, Char.MIN_VALUE)
|
||||||
|
val byteArray = ByteArray(byteBuffer.remaining())
|
||||||
|
byteBuffer.get(byteArray)
|
||||||
|
Wiper.wipe(byteBuffer)
|
||||||
return byteArray
|
return byteArray
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,10 +8,21 @@ import sushi.hardcore.droidfs.Constants
|
|||||||
import sushi.hardcore.droidfs.R
|
import sushi.hardcore.droidfs.R
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
import java.nio.ByteBuffer
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
|
|
||||||
object Wiper {
|
object Wiper {
|
||||||
|
fun wipe(byteBuffer: ByteBuffer) {
|
||||||
|
if (byteBuffer.hasArray()) {
|
||||||
|
Arrays.fill(byteBuffer.array(), Byte.MIN_VALUE)
|
||||||
|
} else {
|
||||||
|
for (i in 0 until byteBuffer.limit()) {
|
||||||
|
byteBuffer.put(i, Byte.MIN_VALUE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private const val buff_size = 4096
|
private const val buff_size = 4096
|
||||||
fun wipe(context: Context, uri: Uri): String? {
|
fun wipe(context: Context, uri: Uri): String? {
|
||||||
val cursor = context.contentResolver.query(uri, null, null, null, null)
|
val cursor = context.contentResolver.query(uri, null, null, null, null)
|
||||||
|
Loading…
Reference in New Issue
Block a user