0

I want to convert this VB.NET code to use in an Android Studio Project (JAVA)

Imports System.Text
Imports System.Security.Cryptography

Public Class Form1
    Public Function md5hash(ByVal txt As String)
        Dim md5 As MD5 = New MD5CryptoServiceProvider
        md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(txt))
        Dim reslt As Byte() = md5.Hash
        Dim strbuilder As New StringBuilder
        For i As Integer = 0 To reslt.Length - 1
            strbuilder.Append(reslt(i).ToString("x2"))
        Next
        Dim ss As String = strbuilder.ToString
        Dim newss As String = ss.Substring(0, 4) + "-" + ss.Substring(4, 4) + "-" + ss.Substring(8, 4) + "-" + ss.Substring(12, 4) + "-" + ss.Substring(16, 4)
        Return newss.ToUpper
    End Function


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TxtKey.Text = md5hash(TxtID.Text)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

How can I do this? To convert VB.NET Visual Basic 2010 script into android studio java

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • Rules here don't allow putting tags or "urgent" in the title. But also, there's just not enough to go on in this question. We don't even know which language you're using! (Android Studio supports several) You need at least **something** of your own code to get us started or you're not gonna get an answer, no matter how much you beg. – Joel Coehoorn Jan 27 '23 at 01:23
  • Also: you know this function returns only an incomplete/partial hash, right? – Joel Coehoorn Jan 27 '23 at 01:35
  • But you can visit this address on an Android phone's browser and edit the input string to get a result whenever you need: https://dotnetfiddle.net/7n810T – Joel Coehoorn Jan 27 '23 at 01:47
  • https://stackoverflow.com/questions/415953/how-can-i-generate-an-md5-hash-in-java – Joel Coehoorn Jan 27 '23 at 02:41

0 Answers0