forked from hardcoresushi/DroidFS
Fix password encoding
This commit is contained in:
parent
9d1bfd606f
commit
e83cfc9794
@ -9,10 +9,11 @@ object WidgetUtil {
|
||||
fun encodeEditTextContent(editText: EditText): ByteArray {
|
||||
val charArray = CharArray(editText.text.length)
|
||||
editText.text.getChars(0, editText.text.length, charArray, 0)
|
||||
val byteArray = StandardCharsets.UTF_8.encode(
|
||||
CharBuffer.wrap(charArray)
|
||||
).array()
|
||||
val byteBuffer = StandardCharsets.UTF_8.encode(CharBuffer.wrap(charArray))
|
||||
Arrays.fill(charArray, Char.MIN_VALUE)
|
||||
val byteArray = ByteArray(byteBuffer.remaining())
|
||||
byteBuffer.get(byteArray)
|
||||
Wiper.wipe(byteBuffer)
|
||||
return byteArray
|
||||
}
|
||||
}
|
@ -8,10 +8,21 @@ import sushi.hardcore.droidfs.Constants
|
||||
import sushi.hardcore.droidfs.R
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.nio.ByteBuffer
|
||||
import java.util.*
|
||||
import kotlin.math.ceil
|
||||
|
||||
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
|
||||
fun wipe(context: Context, uri: Uri): String? {
|
||||
val cursor = context.contentResolver.query(uri, null, null, null, null)
|
||||
|
Loading…
Reference in New Issue
Block a user