burda cdmaCRC.vb ve calculateCRC.vb verilmiş bunu nasıl delphiye göre uyarlarım yada internette bulunun crc32 16 ve diğerlerini denedim ama bana istediğim sonucu vermedıler.mesela bu hex kodunun linkteki verdiğim kaynak kodu ile bana vereceği sonuc su.
Hesaplamasını İstediğim Kod
bu doğru olanı bu ama ben bu hesaplama sistemini çözemedim.internetteki ve forumdaki tüm konulara baktım malasef bir sonuca varamadım.sanırım cdmacrc yada özel bir hesaplama kullanılıyor.bu konu hakkında bilgisi olan biri yardımcı olursa cok sevinirim.şimdiden çok teşekkür ederim...
Bu linkte online CRC Calculator (Javascript) var.
Sizinki hangisi ?
cdmaCRC olanınkini aşağıdaki şekilde dönüştürdüm ama sonuç beklediğin ile benzeşmiyor. 9E2B çıkıyor...
Genel bir açıklama yerine bir koda yönlendirirsen daha çok yardımcı olabiliriz. Yoksa verdiğin linkteki tüm kodları Delphi'ye dönüştürün ben içinden seçerim gibisinden olmaz değil mi
Function ComputeChecksum(ByteDiziDeger:TBytes): UShort;
Var
xtable : Array[0..254] of UShort;
procedure TableDoldur;
Const
poly : UShort = 4129;
Var
i, j :Integer;
temp : UShort;
a : UShort;
begin
For i := low(xtable) to high(xtable) do
begin
temp := 0;
a := UShort((i shl 8));
For j:= 0 To 7 do
begin
If ((temp Xor a) And 32768) <> 0
then temp := UShort(((temp shl 1) XOR poly))
else temp := temp shl 1;
a := a shl 1;
end;
xtable[i]:= temp;
end;
End;
Var
crc :UShort;
i : Integer;
begin
TableDoldur();
crc := 0;
For i := Low(ByteDiziDeger) To High(ByteDiziDeger)
do crc := UShort(((crc shl 8) Xor xtable[((crc shr 8) Xor (255 And ByteDiziDeger[i]))]));
Result := crc;
end;
procedure TForm1.BitBtn5Click(Sender: TObject);
Var
a : TBytes;
begin
a := [$11,$11,$11,$11,$11,$11,$11,$1A];
InputBox('', '', Format('%x', [ ComputeChecksum( a )] ) );
end;
'' CDMA DEV TERM
'' Copyright (c) Dillon Graham 2010-2012 Chromableed Studios
'' www.chromableedstudios.com
'' chromableedstudios ( a t ) gmail ( d o t ) com
''
'' cdmadevterm by ¿k? with help from ajh and jh
''
'' this was originally developed as a test framework, before many
'' things about qcdm(and programming) were understood by the author
'' please forgive some code that should never have seen the light of day ;)
''
''-------------------------------------------------------------------------------------------------------------
'' CDMA DEV TERM is released AS-IS without any warranty of any thing, blah blah blah, under the GPL v3 licence
'' check out the GPL v3 for details
'' http://www.gnu.org/copyleft/gpl.html
''-------------------------------------------------------------------------------------------------------------
Public Class calculateCRC
''sometimes profoundly stupid ways to do things are computationaly unimportant. eh.
Function flipBitsOfSingleByteAsString(ByVal singleByte As String) As String
If singleByte = "0" Then
Return "0"
ElseIf singleByte = "1" Then
Return "8"
ElseIf singleByte = "2" Then
Return "4"
ElseIf singleByte = "3" Then
Return "C"
ElseIf singleByte = "4" Then
Return "2"
ElseIf singleByte = "5" Then
Return "A"
ElseIf singleByte = "6" Then
Return "6"
ElseIf singleByte = "7" Then
Return "E"
ElseIf singleByte = "8" Then
Return "1"
ElseIf singleByte = "9" Then
Return "9"
ElseIf singleByte = "A" Then
Return "5"
ElseIf singleByte = "B" Then
Return "D"
ElseIf singleByte = "C" Then
Return "3"
ElseIf singleByte = "D" Then
Return "B"
ElseIf singleByte = "E" Then
Return "7"
Else
Return "F"
End If
End Function
Dim testArray() As Byte = {&H75, &H6E}
Dim singleByte As Byte
Dim wholeByteArray As Byte()
''not used anymore
''Public Function flipByte(ByVal inByte As Byte) As Byte
'' ''its easy as abc
'' Dim inString As String = inByte.ToString()
'' Dim a As String = inString(0)
'' Dim b As String = inString(1)
'' Dim c As String = (flipBitsOfSingleByteAsString(b) + flipBitsOfSingleByteAsString(a))
'' ''123
'' Dim flippedByte As Byte = Val("&H" + c)
'' Return flippedByte
''End Function
Public Function doStep3theInvert(ByVal inByte As Byte()) As Byte()
''think this does the inverse
''Dim test6() As Byte = {&H5B, &H16}
''TODO test code nt32 vs i nt64
Dim theValueOfTheArray As Int64 = Val("&H" + cdmaTerm.biznytesToStrizings(inByte))
Dim a As Boolean = True
Dim workingWitBytes() As Byte = BitConverter.GetBytes((a Xor (theValueOfTheArray)))
Dim dosBytes(1) As Byte
dosBytes(0) = workingWitBytes(1)
dosBytes(1) = workingWitBytes(0)
''dosbytes is out as byte array
Return dosBytes
''logger.addToLog("test6: " + cdmaTerm.biznytesToStrizings(dosBytes))
End Function
Public Function FLiPallBytesInByteArray(ByVal inByteArray As Byte()) As Byte()
Try
Dim buildABearBuildAString As String = ""
Dim buildABearStartingString As String = cdmaTerm.biznytesToStrizings(inByteArray)
''TODO random test/ try and fix crc
''For n = 0 To (buildABearStartingString.Length / 2)
For n = 0 To (buildABearStartingString.Length - 1)
Dim a As String = flipBitsOfSingleByteAsString(buildABearStartingString(n))
Dim b As String = flipBitsOfSingleByteAsString(buildABearStartingString(n + 1))
buildABearBuildAString += b + a
n = n + 1
Next
'' Return FLiPpeDbytaArray
Return cdmaTerm.String_To_Bytes(buildABearBuildAString)
Catch
logger.addToLog("calculateCRC.FLiPallBytesInByteArray error")
Return testArray
End Try
End Function
End Class
'' CDMA DEV TERM
'' Copyright (c) Dillon Graham 2010-2012 Chromableed Studios
'' www.chromableedstudios.com
'' chromableedstudios ( a t ) gmail ( d o t ) com
''
'' cdmadevterm by ¿k? with help from ajh and jh
''
'' this was originally developed as a test framework, before many
'' things about qcdm(and programming) were understood by the author
'' please forgive some code that should never have seen the light of day ;)
''
''-------------------------------------------------------------------------------------------------------------
'' CDMA DEV TERM is released AS-IS without any warranty of any thing, blah blah blah, under the GPL v3 licence
'' check out the GPL v3 for details
'' http://www.gnu.org/copyleft/gpl.html
''-------------------------------------------------------------------------------------------------------------
Imports System
Public Enum InitialCrcValue
Zeros
NonZero1 = 65535
NonZero2 = 7439
End Enum
Public Class cdmaCRC
Const poly As UShort = 4129
Private table As UShort() = New UShort(255) {}
Private initialValue As UShort = 0
Public Function ComputeChecksum(ByVal bytes As Byte()) As UShort
Dim crc As UShort = Me.initialValue
For i As Integer = 0 To bytes.Length - 1
crc = CUShort(((crc << 8) Xor table(((crc >> 8) Xor (255 And bytes(i))))))
Next
Return crc
End Function
Public Function ComputeChecksumBytes(ByVal bytes As Byte()) As Byte()
Dim crc As UShort = ComputeChecksum(bytes)
Return New Byte() {CByte((crc >> 8)), CByte((crc And 255))}
End Function
Public Sub New(ByVal initialValue As InitialCrcValue)
Me.initialValue = CUShort(initialValue)
Dim temp As UShort, a As UShort
For i As Integer = 0 To table.Length - 1
temp = 0
a = CUShort((i << 8))
For j As Integer = 0 To 7
If ((temp Xor a) And 32768) <> 0 Then
temp = CUShort(((temp << 1) Xor poly))
Else
temp <<= 1
End If
a <<= 1
Next
table(i) = temp
Next
End Sub
End Class
hocam tabi bu kodlar vbye ait ve oluyor bunu delphiye göre dönüştüremedim..bunların ıkısıde aynı programda mevcut sanırım ıkısınıde kullanıyor
Zaten cdmaCRC olarak verdiğini dönüştürdüm. Diğerine benzer şekilde biraz uğraş. Çok zor gelmemeli, çünkü verdiğim dönüştürülmüş kod ile orjinale bakarak başarabilirsin.
Sonra çalışmayan noktalarda sana yardımcı oluruz. İyi niyetli olarak ilk adımı attım, elini taşın altına sokma zamanı geldi. Geç bile oldu...
Zaten cdmaCRC olarak verdiğini dönüştürdüm. Diğerine benzer şekilde biraz uğraş. Çok zor gelmemeli, çünkü verdiğim dönüştürülmüş kod ile orjinale bakarak başarabilirsin.
Sonra çalışmayan noktalarda sana yardımcı oluruz. İyi niyetli olarak ilk adımı attım, elini taşın altına sokma zamanı geldi. Geç bile oldu...
aynen haklısınız hocam bakıyorum zaten.ben zaten hazır kod alıp kopyalayım peşinde değilim..ilerde sorun cıktıgında herzaman hazır kodlarla sorunu çözemem.hemen bakıyorum çözüme ulaşırsam hemen yazarım hayırlı akşamlar..