MD5(new)
This commit is contained in:
parent
5e21716327
commit
8062ee5f88
@ -15,6 +15,7 @@ import android.content.SharedPreferences
|
||||
import android.net.wifi.WifiEnterpriseConfig
|
||||
import android.widget.Toast
|
||||
import java.lang.Exception
|
||||
import java.math.BigInteger
|
||||
import java.security.MessageDigest
|
||||
|
||||
|
||||
@ -33,6 +34,10 @@ class ChangePass : Fragment(){
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val sharedPreference =
|
||||
requireActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE)
|
||||
val savedString = sharedPreference.getString("STRING_KEY", null)
|
||||
Toast.makeText(requireActivity(),savedString,Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
@ -87,38 +92,9 @@ class ChangePass : Fragment(){
|
||||
}
|
||||
|
||||
|
||||
private fun byteArrayToHexString( array: Array<Byte> ): String {
|
||||
|
||||
val result = StringBuilder(array.size * 2)
|
||||
|
||||
for ( byte in array ) {
|
||||
|
||||
val toAppend =
|
||||
String.format("%2X", byte).replace(" ", "0") // hexadecimal
|
||||
result.append(toAppend).append("-")
|
||||
}
|
||||
result.setLength(result.length - 1) // remove last '-'
|
||||
|
||||
return result.toString()
|
||||
}
|
||||
|
||||
|
||||
private fun toMD5Hash( text: String ): String {
|
||||
|
||||
var result = ""
|
||||
|
||||
result = try {
|
||||
|
||||
val md5 = MessageDigest.getInstance("MD5")
|
||||
val md5HashBytes = md5.digest(text.toByteArray()).toTypedArray()
|
||||
|
||||
byteArrayToHexString(md5HashBytes)
|
||||
} catch ( e: Exception) {
|
||||
|
||||
"error: ${e.message}"
|
||||
}
|
||||
|
||||
return result
|
||||
private fun toMD5Hash(input:String): String {
|
||||
val md = MessageDigest.getInstance("MD5")
|
||||
return BigInteger(1, md.digest(input.toByteArray())).toString(16).padStart(32, '0')
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@ import com.example.tasklist.databinding.FragmentLoginPageBinding
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.Toast
|
||||
import java.lang.Exception
|
||||
import java.math.BigInteger
|
||||
import java.security.MessageDigest
|
||||
import java.util.*
|
||||
|
||||
@ -79,38 +80,9 @@ class LoginPage : Fragment(){
|
||||
}
|
||||
}
|
||||
|
||||
private fun byteArrayToHexString( array: Array<Byte> ): String {
|
||||
|
||||
val result = StringBuilder(array.size * 2)
|
||||
|
||||
for ( byte in array ) {
|
||||
|
||||
val toAppend =
|
||||
String.format("%2X", byte).replace(" ", "0") // hexadecimal
|
||||
result.append(toAppend).append("-")
|
||||
}
|
||||
result.setLength(result.length - 1) // remove last '-'
|
||||
|
||||
return result.toString()
|
||||
}
|
||||
|
||||
|
||||
private fun toMD5Hash( text: String ): String {
|
||||
|
||||
var result = ""
|
||||
|
||||
result = try {
|
||||
|
||||
val md5 = MessageDigest.getInstance("MD5")
|
||||
val md5HashBytes = md5.digest(text.toByteArray()).toTypedArray()
|
||||
|
||||
byteArrayToHexString(md5HashBytes)
|
||||
} catch ( e: Exception) {
|
||||
|
||||
"error: ${e.message}"
|
||||
}
|
||||
|
||||
return result
|
||||
private fun toMD5Hash(input:String): String {
|
||||
val md = MessageDigest.getInstance("MD5")
|
||||
return BigInteger(1, md.digest(input.toByteArray())).toString(16).padStart(32, '0')
|
||||
}
|
||||
|
||||
}
|
@ -11,6 +11,7 @@ import androidx.databinding.DataBindingUtil
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.example.tasklist.databinding.FragmentSetPassBinding
|
||||
import java.lang.Exception
|
||||
import java.math.BigInteger
|
||||
import java.security.MessageDigest
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
@ -69,38 +70,9 @@ class SetPass : Fragment() {
|
||||
}.apply()
|
||||
}
|
||||
|
||||
private fun byteArrayToHexString( array: Array<Byte> ): String {
|
||||
|
||||
val result = StringBuilder(array.size * 2)
|
||||
|
||||
for ( byte in array ) {
|
||||
|
||||
val toAppend =
|
||||
String.format("%2X", byte).replace(" ", "0") // hexadecimal
|
||||
result.append(toAppend).append("-")
|
||||
}
|
||||
result.setLength(result.length - 1) // remove last '-'
|
||||
|
||||
return result.toString()
|
||||
}
|
||||
|
||||
|
||||
private fun toMD5Hash( text: String ): String {
|
||||
|
||||
var result = ""
|
||||
|
||||
result = try {
|
||||
|
||||
val md5 = MessageDigest.getInstance("MD5")
|
||||
val md5HashBytes = md5.digest(text.toByteArray()).toTypedArray()
|
||||
|
||||
byteArrayToHexString(md5HashBytes)
|
||||
} catch ( e: Exception ) {
|
||||
|
||||
"error: ${e.message}"
|
||||
}
|
||||
|
||||
return result
|
||||
private fun toMD5Hash(input:String): String {
|
||||
val md = MessageDigest.getInstance("MD5")
|
||||
return BigInteger(1, md.digest(input.toByteArray())).toString(16).padStart(32, '0')
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user