我建议的答案是:如果你反编译它的游戏结束了,为任何类型的软。OP问:“我怎样才能让它变得更难一点?”。这就是答案。IL代表什么?谷歌没有把它捡起来。然后你还可以检查调用程序集的公钥,这会更容易,对吗? 'Note this class in C# will
我建议的答案是:如果你反编译它的游戏结束了,为任何类型的软。OP问:“我怎样才能让它变得更难一点?”。这就是答案。IL代表什么?谷歌没有把它捡起来。然后你还可以检查调用程序集的公钥,这会更容易,对吗? 'Note this class in C# will,c#,.net,C#,.net,我建议的答案是:如果你反编译它的游戏结束了,为任何类型的软。OP问:“我怎样才能让它变得更难一点?”。这就是答案。IL代表什么?谷歌没有把它捡起来。然后你还可以检查调用程序集的公钥,这会更容易,对吗? 'Note this class in C# will (and MUST) be Sealed, which is the equivalent in VB of NotInheritable with Shared Members Public NotInheritable Class Pro
我建议的答案是:如果你反编译它的游戏结束了,为任何类型的软。OP问:“我怎样才能让它变得更难一点?”。这就是答案。IL代表什么?谷歌没有把它捡起来。然后你还可以检查调用程序集的公钥,这会更容易,对吗?
'Note this class in C# will (and MUST) be Sealed, which is the equivalent in VB of NotInheritable with Shared Members
Public NotInheritable Class ProtectMyDLL
Private Shared ReadOnly MyPublicKey As String = "<RSAKeyValue><Modulus>SomeLongBase64StringHere</Modulus><Exponent>SomeShortBase64StringHere</Exponent></RSAKeyValue>"
Private Shared _DataToSign(32) As Byte 'Recommended size in Bytes, for SHA256 hash signature (256 bits = 32 bytes)
Public Shared Property SignedData As Byte() 'The caller will be asked to put the signed version of DataToSign here
Public Shared ReadOnly Property DataToSign As Byte()
Get
If _DataToSign Is Nothing Then 'If empty then generate a new random string (string size is determined by the size of the Byte() array: 32)
Using MyRndGen = System.Security.Cryptography.RandomNumberGenerator.Create
MyRndGen.GetBytes(_DataToSign)
End Using
End If
Return _DataToSign
End Get
End Property
Public Shared Function UserIsGenuine() As Boolean
Using MyRSA As New System.Security.Cryptography.RSACryptoServiceProvider
MyRSA.FromXmlString(MyPublicKey)
UserIsGenuine = MyRSA.VerifyData(DataToSign,
System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"),
SignedData)
_DataToSign = Nothing 'This forces the data to be signed to change each time an access to the DLL is granted; otherwise the data to be signed will change only each time the Application is started. Argueably necessary, argueably consumming unnecessary resources..
End Using
End Function
End Class
Public Class MySecretClass
Public Shared Sub IntelectualPropertyMethod()
If Not ProtectMyDLL.UserIsGenuine() Then
Throw New System.AccessViolationException("Caller signature could not be verified.")
Exit Sub
End If
'... This code is protected
End Sub
End Class
Public Class CallerFromOutsideTheProtectedDLL
Public Sub Main()
ProtectMyDLL.SignedData = SignData(ProtectMyDLL.DataToSign) 'Must do this before every calls of a protected method, unless the _DataToSign = Nothing line is removed, in which case you onlyned to add this line once (see Secret DLL file).
Call MySecretClass.IntelectualPropertyMethod()
End Sub
Private Function SignData(MyData As Byte()) As Byte()
Return MyCrypto.SignWithMyPrivateKey(MyData) 'If you want to avoid having to provide a Private Key in an assembly, you can pass MyData through a WebAPI where the Private Key would be 100% securely kept secret. But then your App needs an access to the web, at least from times to times.
End Function
End Class