아래 내가내가 Vb.Net에서 Copymem 해방 "의 Kernal32"별칭 "RtlMoveMemory에"를 기록하는 방식으로
지금 여기 vb.net에서 사용 어떻게 내 VB6 코드 LIB
Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Property Let Key(New_Value As String)
Dim i As Long
Dim j As Long
Dim K As Long
Dim dataX As Long
Dim datal As Long
Dim datar As Long
Dim Key() As Byte
Dim KeyLength As Long
'Do nothing if the key is buffered
If (m_KeyValue = New_Value) Then Exit Property
m_KeyValue = New_Value
'Convert the new key into a bytearray
KeyLength = Len(New_Value)
Key() = StrConv(New_Value, vbFromUnicode)
'Create key-dependant p-boxes
j = 0
For i = 0 To (ROUNDS + 1)
dataX = 0
For K = 0 To 3
Call CopyMem(ByVal VarPtr(dataX) + 1, dataX, 3) 'the problem is here
dataX = (dataX Or Key(j))
j = j + 1
If (j >= KeyLength) Then j = 0
Next
m_pBox(i) = m_pBox(i) Xor dataX
Next
End Property
CopyMem 서브입니다 여기에 같은
Private Declare Sub CopyMem Lib "KERNEL32" Alias "RtlMoveMemory" (ByVal pDst As Object, ByVal pSrc As Object, ByVal ByteLen As Integer)
Public WriteOnly Property Key() As String
Set(ByVal Value As String)
Dim i As Long
Dim j As Long
Dim K As Long
Dim dataX As Long
Dim datal As Long
Dim datar As Long
Dim Key() As Byte
Dim KeyLength As Long
'Do nothing if the key is buffered
If (m_KeyValue = Value) Then Exit Property
m_KeyValue = Value
'Convert the new key into a bytearray
KeyLength = Len(Value)
Key = System.Text.Encoding.Unicode.GetBytes(Value)
'Create key-dependant p-boxes
j = 0
For i = 0 To (ROUNDS + 1)
dataX = 0
For K = 0 To 3
CopyMem(VarPtr(dataX) + 1, dataX, 3) ' the problem is here
dataX = (dataX Or Key(j))
j = j + 1
If (j >= KeyLength) Then j = 0
Next
m_pBox(i) = m_pBox(i) Xor dataX
Next
End Property
내 vb.net 코드는 VarPtr
Public Function VarPtr(ByVal e As Object) As Object
Dim GC As GCHandle = GCHandle.Alloc(e, GCHandleType.Pinned)
Dim GC2 As Integer = GC.AddrOfPinnedObject.ToInt32
GC.Free()
Return GC2
End Function
에 대한 코드입니다
은 내가 Equivalent of CopyMemory in .NET
에 대해 참조했지만 여전히 나는이
하십시오 누군가의 도움을 받고 있지 않다!
죄송합니다. 질문이 없습니다 ("작동하지 않는다"는 질문이 아닙니다). – Richard
CopyMem (VarPtr (dataX) + 1, dataX, 3) '문제는 여기에 있습니다. 무한대로 연결되거나 아무런 오류가 없습니다. – Dandy
* 질문에 * 입력하십시오. 추신. 'Array' 배열로'Array.Copy'의 문제점은 무엇입니까? 조달청. 당신은 자신의 암호 작성을 시도하는 것처럼 보입니다. "누구나 깨뜨릴 수없는 알고리즘을 쓸 수 있으며, 다른 사람들이 깨뜨릴 수 있는지 여부에 대해서는 아무 것도 말하지 않습니다." – Richard