From 5fd9e745b70c60b9ffbacb25c1b634072caa1f22 Mon Sep 17 00:00:00 2001 From: Chikyun Date: Sun, 5 May 2019 22:30:23 +0900 Subject: [PATCH] initial commit --- EnDec.vb | 137 ++++++++++++++ Form1.Designer.vb | 86 +++++++++ Form1.resx | 120 ++++++++++++ Form1.vb | 107 +++++++++++ My Project/Application.Designer.vb | 38 ++++ My Project/Application.myapp | 11 ++ My Project/AssemblyInfo.vb | 35 ++++ My Project/Resources.Designer.vb | 63 +++++++ My Project/Resources.resx | 117 ++++++++++++ My Project/Settings.Designer.vb | 73 ++++++++ My Project/Settings.settings | 7 + MyAuth.vb | 70 +++++++ MyINI2.vb | 287 +++++++++++++++++++++++++++++ app.config | 23 +++ 인증날짜변경.vbproj | 158 ++++++++++++++++ 15 files changed, 1332 insertions(+) create mode 100644 EnDec.vb create mode 100644 Form1.Designer.vb create mode 100644 Form1.resx create mode 100644 Form1.vb create mode 100644 My Project/Application.Designer.vb create mode 100644 My Project/Application.myapp create mode 100644 My Project/AssemblyInfo.vb create mode 100644 My Project/Resources.Designer.vb create mode 100644 My Project/Resources.resx create mode 100644 My Project/Settings.Designer.vb create mode 100644 My Project/Settings.settings create mode 100644 MyAuth.vb create mode 100644 MyINI2.vb create mode 100644 app.config create mode 100644 인증날짜변경.vbproj diff --git a/EnDec.vb b/EnDec.vb new file mode 100644 index 0000000..18318e2 --- /dev/null +++ b/EnDec.vb @@ -0,0 +1,137 @@ +Imports System.Security.Cryptography + +Public Class EnDec + + Private TripleDes As New TripleDESCryptoServiceProvider + Sub New(ByVal key As String) + ' Initialize the crypto provider. + TripleDes.Key = TruncateHash(key, TripleDes.KeySize \ 8) + TripleDes.IV = TruncateHash("", TripleDes.BlockSize \ 8) + End Sub + + Private Function TruncateHash( _ + ByVal key As String, _ + ByVal length As Integer) _ + As Byte() + + Dim sha1 As New SHA1CryptoServiceProvider + + ' Hash the key. + Dim keyBytes() As Byte = _ + System.Text.Encoding.Unicode.GetBytes(key) + Dim hash() As Byte = sha1.ComputeHash(keyBytes) + + ' Truncate or pad the hash. + ReDim Preserve hash(length - 1) + Return hash + End Function + + ''' + ''' 문자열의 암호화 + ''' + ''' + ''' + ''' + Public Function EncryptData( _ + ByVal plaintext As String) _ + As String + + ' Convert the plaintext string to a byte array. + Dim plaintextBytes() As Byte = _ + System.Text.Encoding.Unicode.GetBytes(plaintext) + + ' Create the stream. + Dim ms As New System.IO.MemoryStream + ' Create the encoder to write to the stream. + Dim encStream As New CryptoStream(ms, _ + TripleDes.CreateEncryptor(), _ + System.Security.Cryptography.CryptoStreamMode.Write) + + ' Use the crypto stream to write the byte array to the stream. + encStream.Write(plaintextBytes, 0, plaintextBytes.Length) + encStream.FlushFinalBlock() + + ' Convert the encrypted stream to a printable string. + Return Convert.ToBase64String(ms.ToArray) + End Function + + ''' + ''' 복호화' + ''' + ''' + ''' + ''' + Public Function DecryptData( _ + ByVal encryptedtext As String) _ + As String + + ' Convert the encrypted text string to a byte array. + Dim encryptedBytes() As Byte = Convert.FromBase64String(encryptedtext) + + ' Create the stream. + Dim ms As New System.IO.MemoryStream + ' Create the decoder to write to the stream. + Dim decStream As New CryptoStream(ms, _ + TripleDes.CreateDecryptor(), _ + System.Security.Cryptography.CryptoStreamMode.Write) + + ' Use the crypto stream to write the byte array to the stream. + decStream.Write(encryptedBytes, 0, encryptedBytes.Length) + decStream.FlushFinalBlock() + + ' Convert the plaintext stream to a string. + Return System.Text.Encoding.Unicode.GetString(ms.ToArray, 0, ms.Length) + End Function + + ''' + ''' 파일로부터 문자열을 읽어옵니다. + ''' + ''' + ''' + Public Function Read_STring(ByVal Filename As String) As String + Dim FI As New System.IO.FileInfo(Filename) + If FI.Exists = False Then + MsgBox("필수파일이 존재하지않습니다", MsgBoxStyle.Critical, "확인") + Return "" + End If + + Dim FS As New System.IO.FileStream(FI.FullName, IO.FileMode.Open) + Dim SR As New System.IO.StreamReader(FS, System.Text.Encoding.Default) + + Dim cipherText As String = SR.ReadToEnd + SR.Close() + FS.Close() + + ' DecryptData throws if the wrong password is used. + Try + Dim plainText As String = DecryptData(cipherText) + Return plainText + 'MsgBox("해독값은? " & plainText) + Catch ex As System.Security.Cryptography.CryptographicException + Return "" + MsgBox("암호화키가 일치하지않거나 기타 오류입니다") + End Try + + End Function + + ''' + ''' 파일에 해당 문자열을 기록합니다. + ''' + ''' + ''' + ''' + Public Sub Write_String(ByVal Filename As String, ByVal Contents As String) + Dim cipherText As String = EncryptData(Contents) + + Dim FI As New System.IO.FileInfo(Filename) + Dim FS As New System.IO.FileStream(FI.FullName, IO.FileMode.Create) + Dim SW As New System.IO.StreamWriter(FS, System.Text.Encoding.Default) + 'MsgBox("암호화된값은? " & cipherText) + SW.Write(cipherText) + SW.Flush() + SW.Close() + FS.Close() + End Sub + + +End Class \ No newline at end of file diff --git a/Form1.Designer.vb b/Form1.Designer.vb new file mode 100644 index 0000000..14bd174 --- /dev/null +++ b/Form1.Designer.vb @@ -0,0 +1,86 @@ + _ +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Form은 Dispose를 재정의하여 구성 요소 목록을 정리합니다. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Windows Form 디자이너에 필요합니다. + Private components As System.ComponentModel.IContainer + + '참고: 다음 프로시저는 Windows Form 디자이너에 필요합니다. + '수정하려면 Windows Form 디자이너를 사용하십시오. + '코드 편집기를 사용하여 수정하지 마십시오. + _ + Private Sub InitializeComponent() + Me.Button2 = New System.Windows.Forms.Button() + Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker() + Me.tb_key1 = New System.Windows.Forms.TextBox() + Me.Label1 = New System.Windows.Forms.Label() + Me.SuspendLayout() + ' + 'Button2 + ' + Me.Button2.Location = New System.Drawing.Point(292, 8) + Me.Button2.Name = "Button2" + Me.Button2.Size = New System.Drawing.Size(200, 21) + Me.Button2.TabIndex = 4 + Me.Button2.Text = "인증번호1생성 ->" + Me.Button2.UseVisualStyleBackColor = True + ' + 'DateTimePicker1 + ' + Me.DateTimePicker1.Location = New System.Drawing.Point(86, 8) + Me.DateTimePicker1.Name = "DateTimePicker1" + Me.DateTimePicker1.Size = New System.Drawing.Size(200, 21) + Me.DateTimePicker1.TabIndex = 1 + ' + 'tb_key1 + ' + Me.tb_key1.Location = New System.Drawing.Point(12, 35) + Me.tb_key1.Multiline = True + Me.tb_key1.Name = "tb_key1" + Me.tb_key1.ReadOnly = True + Me.tb_key1.Size = New System.Drawing.Size(480, 68) + Me.tb_key1.TabIndex = 5 + ' + 'Label1 + ' + Me.Label1.Location = New System.Drawing.Point(12, 10) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(68, 17) + Me.Label1.TabIndex = 1 + Me.Label1.Text = "만기일" + Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 12.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(499, 109) + Me.Controls.Add(Me.Button2) + Me.Controls.Add(Me.DateTimePicker1) + Me.Controls.Add(Me.tb_key1) + Me.Controls.Add(Me.Label1) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "Form1" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "번호찰 관리프로그램 인증키 생성 (tindevil@nate.com)" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents Button2 As System.Windows.Forms.Button + Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker + Friend WithEvents tb_key1 As System.Windows.Forms.TextBox + Friend WithEvents Label1 As System.Windows.Forms.Label + +End Class diff --git a/Form1.resx b/Form1.resx new file mode 100644 index 0000000..d58980a --- /dev/null +++ b/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Form1.vb b/Form1.vb new file mode 100644 index 0000000..4bb28b1 --- /dev/null +++ b/Form1.vb @@ -0,0 +1,107 @@ + +Public Class Form1 + Dim install, installkey As Long + Dim fn As String + Dim auth As New MyAuth + + + ''' + ''' оɴϴ. + ''' + ''' + ''' + Private Function ReadAuth() As Boolean + + If install = 0 OrElse installkey = 0 Then + MsgBox(" ʽϴ." & vbCrLf & vbCrLf & "ڿ ϼ", MsgBoxStyle.Critical, "Ȯ") + ' Process.Start(HomePage) + Return False + End If + + If (auth.GetDateNumber(Now)) > install Then + MsgBox(" ʰǾϴ." & vbCrLf & vbCrLf & "ڿ ϼ", MsgBoxStyle.Critical, "Ȯ") + ' Process.Start(HomePage) + Return False '// ʰߴٸ + End If + + If installkey.ToString <> auth.GetDateNumberEnc(install) Then '// ջǾٸ + MsgBox(" ջǾϴ" & vbCrLf & vbCrLf & "ڿ ϼ", MsgBoxStyle.Critical, "Ȯ") + 'Process.Start(HomePage) + Return False + End If + Return True + ' MsgBox(auth.GetDateNumberEnc(Now)) + End Function + + Private Sub SetAuth(ByVal NewDate As Date) + Dim auth As New MyAuth + Dim Arinini As New MyINI2(fn) + Arinini.Write("main", "install", auth.GetDateNumber(NewDate)) + Arinini.Write("main", "installkey", auth.GetDateNumberEnc(NewDate)) + + Dim A As New System.Text.StringBuilder + A.AppendLine(" Ͽ ϵǾϴ") + A.AppendLine("ϸ = " & fn) + A.AppendLine("ش ڿ ,ڵġ,ġ Ͽ") + A.AppendLine(" ϸ˴ϴ") + A.AppendLine("------------------") + A.AppendLine(" : " & Me.DateTimePicker1.Value.ToString) + + MsgBox(A.ToString, MsgBoxStyle.Information, "ϿϷ") + End Sub + + Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click + '// + '//ip εӴ Ȯ + 'Dim IP() As String = Me.tb_ip.Text.Split(".") + 'If IP.Length <> 4 Then + ' MsgBox(" IPּü谡 ƴմϴ" & vbCrLf & "Ǵ 192.168.0.1 Դϴ", MsgBoxStyle.Information, "Ȯ") + ' Return + 'End If + + 'Dim ipsum As Short = 0 + 'For Each a As String In IP + ' If IsNumeric(a) = False Then + ' MsgBox("Ŭ ̴ ڷθ Էϼ." & vbCrLf & "Ǵ 192.168.0.1 Դϴ", MsgBoxStyle.Information, "Ȯ") + ' Return + ' Else + ' ipsum += Val(a) '//Ǹ Ѵ + ' End If + 'Next + Dim yymmdd As String = Format(Me.DateTimePicker1.Value.Date, "yyyy-MM-dd 23:59:59") + Dim textenc As New EnDec("HAEGWANGSIMP") + Me.tb_key1.Text = textenc.EncryptData(yymmdd + "|SIMP|" + yymmdd.GetHashCode().ToString()) + Dim Auth As New MyAuth + 'If Auth.check_key1(Me.tb_key1.Text) = False Then + 'MsgBox("ȣ1α׷ ", MsgBoxStyle.Critical, "Ȯ") + 'End If + End Sub + + Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + + + End Sub + + 'Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) + ' Dim key2 As String = "" + ' For Each C As Control In Me.GroupBox2.Controls + ' ' MsgBox(C.GetType.ToString) + ' If C.GetType.ToString.ToUpper = "SYSTEM.WINDOWS.FORMS.CHECKBOX" Then '//üũڽ ȮѴ. + ' If CType(C, CheckBox).Checked Then key2 &= C.Tag.ToString.ToUpper + ' End If + ' Next + ' If key2 = "" Then + ' Me.tb_key2.Text = "" + ' Else + ' Me.tb_key2.Text = key2 & "%" & key2.GetHashCode + ' Dim Auth As New MyAuth + ' If Auth.Check_key2(Me.tb_key2.Text) = False Then + ' MsgBox("ȣ2α׷ ", MsgBoxStyle.Critical, "Ȯ") + ' End If + ' End If + + + 'End Sub + + +End Class diff --git a/My Project/Application.Designer.vb b/My Project/Application.Designer.vb new file mode 100644 index 0000000..9e2845c --- /dev/null +++ b/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' 이 코드는 도구를 사용하여 생성되었습니다. +' 런타임 버전:4.0.30319.42000 +' +' 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +' 이러한 변경 내용이 손실됩니다. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + '참고: 자동으로 생성되므로 직접 이 파일을 수정하지 마십시오. 변경할 사항이 있거나 + ' 파일에서 빌드 오류가 발생하는 경우 프로젝트 디자이너로 + ' 이동([프로젝트 속성]으로 이동하거나 솔루션 탐색기에서 My Project 노드를 + ' 두 번 클릭)한 다음 [응용 프로그램] 탭에서 변경하십시오. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.인증날짜변경.Form1 + End Sub + End Class +End Namespace diff --git a/My Project/Application.myapp b/My Project/Application.myapp new file mode 100644 index 0000000..1243847 --- /dev/null +++ b/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..d3c4373 --- /dev/null +++ b/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +' 어셈블리와 관련된 정보를 수정하려면 +' 이 특성 값을 변경하십시오. + +' 어셈블리 특성 값을 검토합니다. + + + + + + + + + + +'이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. + + +' 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +' +' 주 버전 +' 부 버전 +' 빌드 번호 +' 수정 버전 +' +' 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +' 지정되도록 할 수 있습니다. +' + + + diff --git a/My Project/Resources.Designer.vb b/My Project/Resources.Designer.vb new file mode 100644 index 0000000..6a6daf4 --- /dev/null +++ b/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' 이 코드는 도구를 사용하여 생성되었습니다. +' 런타임 버전:4.0.30319.42000 +' +' 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +' 이러한 변경 내용이 손실됩니다. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + '이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder + '클래스에서 자동으로 생성되었습니다. + '멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을 + '다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. + ''' + ''' 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("인증날짜변경.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대한 현재 스레드의 CurrentUICulture + ''' 속성을 재정의합니다. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/My Project/Resources.resx b/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/My Project/Settings.Designer.vb b/My Project/Settings.Designer.vb new file mode 100644 index 0000000..a5f07bd --- /dev/null +++ b/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' 이 코드는 도구를 사용하여 생성되었습니다. +' 런타임 버전:4.0.30319.42000 +' +' 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +' 이러한 변경 내용이 손실됩니다. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "My.Settings 자동 저장 기능" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.인증날짜변경.My.MySettings + Get + Return Global.인증날짜변경.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/My Project/Settings.settings b/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/MyAuth.vb b/MyAuth.vb new file mode 100644 index 0000000..05a571b --- /dev/null +++ b/MyAuth.vb @@ -0,0 +1,70 @@ +Public Class MyAuth '//각종인증방법을 이용한다. + Public Function GetDateAuth(ByVal 만기일자 As Date) As Boolean '//날짜인증시 사용가능한지 + '//사용가능한 날짜인지 확인하고 만약 날짜정보가 없으면은 날짜를 setdataeauth 를 실행합니다 + '//인터넷에 연결되어있을시 현재 시간정보를 인터넷에서 받아온ㄷ + '//콘솔의 현재날짜가 설치된 날짜보다 더 뒤일경우 사용중지 + '//레지 파일의 기록날짜가 서로다를경우 사용중지 + '//레지,파일의 기록날짜가 동일하고 콘솔의 현재날짜가 기한을 넘지않았을경우에만 true 한다. + Dim isAvailable As Boolean = My.Computer.Network.IsAvailable '//인터넷사용여부 + Dim CurrentDate As Date + + If isAvailable Then '//인터넷에서 날짜정보를 가져온다 기록된 날짜와 오늘의 날짜를 확인한다. + Dim Itime As Date + Try + CurrentDate = Itime + Catch ex As Exception '//에러발생시 콘솔날짜로 세팅한다. + CurrentDate = Now + End Try + Else + MsgBox("인터넷사용불가") + CurrentDate = Now + End If + + If 만기일자 > CurrentDate Then Return False + Return True + End Function + + Public Sub SetAuth(ByVal Newkey As String, ByVal Fn As String) + ' Dim auth As New ARINCLASS + Dim Arinini As New MyINI2(Fn) + Arinini.Write("main", "install2", Newkey) + Arinini.Write("main", "installkey2", Newkey.GetHashCode) + + Dim A As New System.Text.StringBuilder + A.AppendLine("인증정보가 파일에 기록되었습니다") + A.AppendLine("만기일 : " & Date.FromFileTimeUtc(Newkey)) + MsgBox(A.ToString, MsgBoxStyle.Information, "기록완료") + End Sub + + + ''' + ''' 미지원 함수 + ''' + ''' + ''' + Public Function SetDateAuth() As Boolean '//레지와 파일에 해당 인증정보를 기록합니다 + Return True + End Function + + ''' + ''' 미지원함수 + ''' + ''' + ''' + Public Function GetCurrentDate() As Date '//오늘날짜를 가져옵니다 + Return Now + End Function + + Public Function GetDateNumber(ByVal 시작일 As Date) As Long + Return 시작일.ToFileTimeUtc + End Function + + Public Function GetDateNumberEnc(ByVal 시작일 As Date) As String + Return 시작일.ToFileTimeUtc.ToString.GetHashCode '//날짜로 들어가면 날짜의 해쉬코드를 넘겨준다. + End Function + + Public Function GetDateNumberEnc(ByVal 시작일 As Long) As String + Return 시작일.ToString.GetHashCode + End Function + +End Class diff --git a/MyINI2.vb b/MyINI2.vb new file mode 100644 index 0000000..59f3ecf --- /dev/null +++ b/MyINI2.vb @@ -0,0 +1,287 @@ +Imports System.IO + +Public Class MyINI2 + Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer + Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpDownFileName As String) As Integer + 'Private Aname As String + Public FileName As String = vbNullString + Private FileNameBuf As String + Private m_sPath As String + Private m_sKey As String + Private m_sSection As String + Private m_sDefault As String + Private m_lLastReturnCode As Integer + + Public Sub New(ByVal File As String) + FileName = File + FileNameBuf = File + Me.Create() + + 'MsgBox("New 1=" & FileName & vbCrLf & "2=" & FileNameBuf) + + ' If Not System.IO.File.Exists(File) Then System.IO.File.Create(File) + End Sub + Public Sub Create() + If Exist() = True Then Return + Dim A As New IO.FileInfo(FileName) + A.Directory.Create() + Dim FS As IO.FileStream = A.Create() + Dim SW As New IO.StreamWriter(FS, System.Text.Encoding.Default) + SW.WriteLine("//Myini 로부터 자동생성된 파일입니다") + SW.WriteLine("//생성일자 : " & Now.ToString) + SW.Flush() + SW.Close() + FS.Close() + SW = Nothing + FS = Nothing + FileName = FileNameBuf + End Sub + Public Function Exist() As Boolean + Return System.IO.File.Exists(FileName) + End Function + + Public Function Read(ByVal appkey As String, ByVal subkey As String, Optional ByVal DefaultValue As String = vbNullString) As String '//변수초기화 + 'MsgBox("Read 1=" & FileName & vbCrLf & "2=" & FileNameBuf) + + Dim tempstr As Integer 'ini파일에서 읽어온 값을 임시저장하는 변수 + Dim strtemp As String = New String(Chr(0), 2000) 'ini파일의 임시 변수 + Dim Tempbuf As String + + If Not Exist() Then + MsgBox("환경파일이 존재하지 않습니다" & vbCrLf & "APP=" & appkey & vbCrLf & "subkey=" & subkey & vbCrLf & "파일명=" & FileName, MsgBoxStyle.Critical, "Error") + Return vbNullString + End If + Try + tempstr = GetPrivateProfileString(appkey, subkey, "", strtemp, Len(strtemp), FileName) + Tempbuf = strtemp.Substring(0, tempstr) + Tempbuf = Tempbuf.Trim(Chr(0)) + + FileName = FileNameBuf + + If Tempbuf.Trim = vbNullString AndAlso DefaultValue <> vbNullString Then + Return DefaultValue + Else + Return Tempbuf + End If + Catch ex As Exception + FileName = FileNameBuf + Return vbNullString + End Try + + End Function + Public Function ReadFile(ByVal appkey As String, ByVal subkey As String, ByVal filename2 As String, Optional ByVal DefaultValue As String = vbNullString) As String '//변수초기화 + 'MsgBox("ReadFile 1=" & FileName & vbCrLf & "2=" & FileNameBuf) + Dim tempstr As Integer 'ini파일에서 읽어온 값을 임시저장하는 변수 + Dim strtemp As String = New String(Chr(0), 2000) 'ini파일의 임시 변수 + Dim Tempbuf As String + + If Not System.IO.File.Exists(filename2) Then + MsgBox("환경파일이 존재하지 않습니다" & vbCrLf & "파일명=" & FileName, MsgBoxStyle.Critical, "Error") + Return vbNullString + End If + + Try + tempstr = GetPrivateProfileString(appkey, subkey, "", strtemp, Len(strtemp), filename2) + Tempbuf = strtemp.Substring(0, tempstr) + If Tempbuf.Trim = vbNullString AndAlso DefaultValue <> vbNullString Then + Return DefaultValue + Else + Return Tempbuf + End If + Catch ex As Exception + Return vbNullString + End Try + FileName = FileNameBuf + End Function + + Public Function Write(ByVal appkey As String, ByVal subkey As String, ByVal WriteVal As Object) As Integer + Dim RetVal As Integer + 'MsgBox("Write1 1=" & FileName & vbCrLf & "2=" & FileNameBuf) + If Not Exist() Then + MsgBox("환경파일이 존재하지 않습니다" & vbCrLf & "파일을 생성합니다." & vbCrLf & "파일명=" & FileName, MsgBoxStyle.Information, "확인") + Me.Create() + End If + ' FileName = Aname + RetVal = (WritePrivateProfileString(appkey, subkey, WriteVal, FileName)) + FileName = FileNameBuf + Return RetVal + + End Function + Public Sub Write(ByVal appkey As String, ByVal subkey As String, ByVal WriteVal As Object, ByVal fileName2 As String) + 'MsgBox("Write2 1=" & FileName & vbCrLf & "2=" & FileNameBuf) + If Not System.IO.File.Exists(fileName2) Then + MsgBox("[D] 환경파일이 존재하지 않습니다" & vbCrLf & "파일을 생성합니다." & vbCrLf & "파일명=" & fileName2, MsgBoxStyle.Information, "확인") + System.IO.File.Create(fileName2) + End If + WritePrivateProfileString(appkey, subkey, WriteVal, fileName2) + FileName = FileNameBuf + End Sub + + + + Public Sub EnumerateCurrentSection(ByRef sKey() As String, ByRef iCount As Integer) + Dim sSection As String + Dim iPos As Integer + Dim iNextPos As Integer + Dim sCur As String + + iCount = 0 + Erase sKey + sSection = INISection + If (Len(sSection) > 0) Then + iPos = 1 + iNextPos = InStr(iPos, sSection, Chr(0)) + Do While iNextPos <> 0 + sCur = Mid(sSection, iPos, iNextPos - iPos) + If (sCur <> Chr(0)) Then + iCount = iCount + 1 + 'UPGRADE_WARNING: sKey 배열의 하한이 1에서 0(으)로 변경되었습니다. 자세한 내용은 다음을 참조하십시오. 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="0F1C9BE1-AF9D-476E-83B1-17D43BECFF20"' + ReDim Preserve sKey(iCount) + sKey(iCount) = Mid(sSection, iPos, iNextPos - iPos) + iPos = iNextPos + 1 + iNextPos = InStr(iPos, sSection, Chr(0)) + End If + Loop + End If + End Sub + + + Public Sub GetAllsection(ByVal key As String, ByRef Section As ArrayList, ByRef Value As ArrayList) + Dim FS As New System.IO.FileStream(FileName, FileMode.Open) + Dim SR As New IO.StreamReader(FS, System.Text.Encoding.Default) + Dim Findkey As String = "[" & key & "]" + Dim Line As String + Dim KeyPos As Integer = -1 + Dim Seppos As Integer = -1 + While SR.Peek > -1 + Line = SR.ReadLine + If KeyPos = -1 Then '//키를 못찻았으면 + If Line.ToUpper.IndexOf(Findkey.ToUpper) > -1 Then KeyPos = Line.ToUpper.IndexOf(Findkey.ToUpper) + Else '//찾앗으면 + If Line.IndexOf("[") = -1 Then '//그다음 키가 오기전까지 모두 추가한다. + Seppos = Line.IndexOf("=") + Section.Add(Line.Substring(0, Seppos)) + Value.Add(Line.Substring(Seppos + 1)) + Else + Exit While + End If + End If + End While + + SR.Close() + FS.Close() + + + End Sub + + Public Sub EnumerateAllSections(ByRef sSections() As String, ByRef iCount As Integer) + Dim sIniFile As String + Dim iPos As Integer + Dim iNextPos As Integer + Dim sCur As String + + iCount = 0 + Erase sSections + sIniFile = Sections + If (Len(sIniFile) > 0) Then + iPos = 1 + iNextPos = InStr(iPos, sIniFile, Chr(0)) + Do While iNextPos <> 0 + If (iNextPos <> iPos) Then + sCur = Mid(sIniFile, iPos, iNextPos - iPos) + iCount = iCount + 1 + 'UPGRADE_WARNING: sSections 배열의 하한이 1에서 0(으)로 변경되었습니다. 자세한 내용은 다음을 참조하십시오. 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="0F1C9BE1-AF9D-476E-83B1-17D43BECFF20"' + ReDim Preserve sSections(iCount) + sSections(iCount) = sCur + End If + iPos = iNextPos + 1 + iNextPos = InStr(iPos, sIniFile, Chr(0)) + Loop + End If + + End Sub + + Property INISection() As String + Get + Dim sBuf As String + Dim iSize As String + Dim iRetCode As Short + + sBuf = Space(8192) + iSize = CStr(Len(sBuf)) + iRetCode = GetPrivateProfileString(m_sSection, 0, m_sDefault, sBuf, CInt(iSize), m_sPath) + If (CDbl(iSize) > 0) Then + INISection = Left(sBuf, iRetCode) + Else + INISection = "" + End If + + End Get + Set(ByVal Value As String) + m_lLastReturnCode = WritePrivateProfileString(m_sSection, 0, Value, m_sPath) + End Set + End Property + ReadOnly Property Sections() As String + Get + Dim sBuf As String + Dim iSize As String + Dim iRetCode As Short + + sBuf = Space(8192) + iSize = CStr(Len(sBuf)) + iRetCode = GetPrivateProfileString(0, 0, m_sDefault, sBuf, CInt(iSize), m_sPath) + If (CDbl(iSize) > 0) Then + Sections = Left(sBuf, iRetCode) + Else + Sections = "" + End If + + End Get + End Property + + ReadOnly Property LastReturnCode() As Integer + Get + LastReturnCode = m_lLastReturnCode + End Get + End Property + ReadOnly Property Success() As Boolean + Get + Success = (m_lLastReturnCode <> 0) + End Get + End Property + 'UPGRADE_NOTE: Default이(가) Default_Renamed(으)로 업그레이드되었습니다. 자세한 내용은 다음을 참조하십시오. 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"' + Property Default_Renamed() As String + Get + Default_Renamed = m_sDefault + End Get + Set(ByVal Value As String) + m_sDefault = Value + End Set + End Property + Property Path() As String + Get + Path = m_sPath + End Get + Set(ByVal Value As String) + m_sPath = Value + End Set + End Property + Property Key() As String + Get + Key = m_sKey + End Get + Set(ByVal Value As String) + m_sKey = Value + End Set + End Property + Property Section() As String + Get + Section = m_sSection + End Get + Set(ByVal Value As String) + m_sSection = Value + End Set + End Property + + +End Class \ No newline at end of file diff --git a/app.config b/app.config new file mode 100644 index 0000000..5733a44 --- /dev/null +++ b/app.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/인증날짜변경.vbproj b/인증날짜변경.vbproj new file mode 100644 index 0000000..408c375 --- /dev/null +++ b/인증날짜변경.vbproj @@ -0,0 +1,158 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {B0CC37CF-1CE5-42B4-8E4D-863F8D45B2A2} + WinExe + 인증날짜변경.My.MyApplication + 인증날짜변경 + 인증날짜변경 + WindowsForms + false + + + + + + + 3.5 + v4.0 + + 게시\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + 인증날짜변경.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355 + + + pdbonly + false + true + true + ..\..\..\SIMP\전주번호찰인증키\ + 인증날짜변경.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355 + x86 + + + + False + ..\..\DLLS\CEpole.dll + + + False + ..\..\DLLS\CommonClassv2.dll + + + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + Designer + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + + + \ No newline at end of file