运行截图
布局文件
Main窗体代码如下
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'这里声明的变量能被所有模块使用!
End Sub
Sub Globals
Dim Bconv As ByteConverter
Dim Button1 As Button
Dim EditText1 As EditText
Dim EditText2 As EditText
Dim Label1 As Label
Dim Label2 As Label
Dim Label3 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
Dim data(0) As Byte
Dim md As MessageDigest
Dim msg As String
msg =EditText1.Text
' "MD5" 可以替换成 "SHA-1"
data = Bconv.StringToBytes(msg, "UTF8")
' "MD5" 可以替换成 "SHA-1"
data = md.GetMessageDigest(data, "MD5")
Label3.Text=""
Label3.Text=Bconv.HexFromBytes(data)
End Sub