Posts
[VB.NET]統計英文字串中字母個數
For Each c As Char In inputString idx = Asc(c) - startAscii symbolCount(idx) = symbolCount(idx) + 1 If symbolCount(idx) > symbolCount(maxSymbolIdx) Then maxSymbolIdx = idx End If Next For idx = 0 To 25 Console.Write(Chr(startAscii + idx) & ": ") Console.WriteLine(symbolCount(idx).ToString) Next Console.WriteLine() Console.Write("Max Count Symbol: ") Console.WriteLine(Chr(startAscii + maxSymbolIdx)) End Sub</pre></div><p> </p><h2> </h2><h2>解法二</h2><p> </p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:313a96f2-0f63-4ed7-aa9d-e6b0bc28f245" class="wlWriterEditableSmartContent"><pre class="vb:nocontrols" name="code"> Sub Test(ByVal inputString As String) Dim chars() As Char = inputString.
read morePosts
[.NET Concept][Security].NET程式保護機制概述
//不影響結果 if(i == a){ Console.WriteLine("Some Thing Error!!"); } } 3.加入一些冗贅的運算 int a = 10;改為 int b = 2; int c = 5; int a = b * c; 值得注意的是,使用混淆保護的程式仍是可以使用反組譯工具看到混淆後的MSIL,且很容易被有心人反推回去的,只是增加了反推的難度而已。微軟自帶的Dotfuscator Community Edition好像已經有現成反推回去的程式在網路上流佈,像水瓶大介紹的DF Stack就是一例。 內核級加密保護若採用內核級加密來保護,使用反組譯工具去看MSIL時。會顯示不是CLR程式,無法看到反組譯過後的程式碼。有比混淆稍微安全些的感覺。類似的軟體有MaxToCode、XeonCode。 硬體保護硬體保護方面,有聖天狗、Aladdin等硬體加密鎖。多半這類產品除了本身會提供API可以讓程式呼叫做保護的動作外,也會附上基本的混淆與程式加密功能。 Conclusion在.NET保護這塊我涉略不深,只能做初步的介紹。這邊我要順帶一提,其實我們用來反組譯的.NET Reflector工具在加密上算是還做的不錯。畢竟本身就是反組譯用的工具,在這方面會有一定的程度,網路上也有許多相關研究。有興趣的可以從該工具的保護機制著手研究。像是Reflector保護方法初探等,還有很多篇,請自行打上關鍵字Reflector 保護,Google一下就有了。 LinkMSDN大內高手專欄 - To De or Not to De? DF Stack 1.0 - .NET 的反混淆器?DF StackReflector保護方法初探
read morePosts
[VB.NET]列舉型別字串處理的注意事項
Sub Main() Dim msg As String Dim sex As SexType = SexType.Boy msg = "Sex: " & sex.ToString & " (" & sex & ")" Console.WriteLine(msg) msg = String.Format("Sex: {0} ({1})", sex, CInt(sex)) Console.WriteLine(msg) End Sub End Module 執行結果
read morePosts
[C#][VB.NET].NET 4.0 Barrier Class
Module Module1
Private sync As Barrier Sub Main(ByVal args() As String) sync = New Barrier(3) Dim charlie = New Thread(Sub() DriveToBoston("Charlie", TimeSpan.FromSeconds(1))) charlie.Start() Dim mac = New Thread(Sub() DriveToBoston("Mac", TimeSpan.FromSeconds(2))) mac.Start() Dim dennis = New Thread(Sub() DriveToBoston("Dennis", TimeSpan.FromSeconds(3))) dennis.Start() charlie.Join() mac.Join() dennis.Join() Console.ReadKey() End Sub Sub DriveToBoston(ByVal name As String, ByVal timeToGasStation As TimeSpan) Console.WriteLine("[{0}] Leaving House", name) ' Perform some work Thread.Sleep(timeToGasStation) Console.WriteLine("[{0}] Arrived at Gas Station", name) ' Need to sync here sync.
read more