Public Class fAuth
    Private Sub fAuth_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        '  Runcnt = Me.ReadAuthcount
        If Runcnt > 9 Then
            Button2.Text = "사용횟수초과(테스트사용불가)"
            Button2.Enabled = False
        End If
        Dim remain As Integer = 10 - Runcnt
        Label1.Text = String.Format(Label1.Text, remain)

    End Sub
    Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Dim url As String = "http://haegwang.co.kr"
        Dim prc As New System.Diagnostics.Process()
        Dim si As New System.Diagnostics.ProcessStartInfo(url)
        prc.StartInfo = si
        prc.Start()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim NewKey As String = TextBox1.Text.Trim()
        If NewKey.Trim() = "" Then
            TextBox1.Focus()
            TextBox1.SelectAll()
            Return
        End If

        Dim textenc As New EnDec("HAEGWANGSIMP")
        Try
            Dim strdata As String = textenc.DecryptData(TextBox1.Text.Trim())
            Dim strbuf() As String = strdata.Split("|SIMP|")
            Dim datestr As String = strbuf(0)
            Dim datestrhash As String = strbuf(2)
            Dim hashcode As Integer = CInt(datestrhash)
            If datestr.GetHashCode() = hashcode Then
                Dim auth As New MyAuth
                Dim dateValue As Date = Date.Parse(datestr)
                Dim setfile As String = My.Application.Info.DirectoryPath & "\epole.ini"
                auth.SetAuth(dateValue.ToFileTimeUtc(), setfile)
                MsgBox("프로그램을 재실행 하세요", MsgBoxStyle.Information, "확인")
                DialogResult = Windows.Forms.DialogResult.Cancel
            End If
        Catch ex As Exception
            MsgBox("인증키 확인 중 오류 발생, 다시 시도하세요")
            TextBox1.Focus()
            TextBox1.SelectAll()
            Return
        End Try


       

    End Sub

   
End Class