elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  me ayudan con vb a c++
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: me ayudan con vb a c++  (Leído 2,322 veces)
hacktiger

Desconectado Desconectado

Mensajes: 2


Ver Perfil
me ayudan con vb a c++
« en: 16 Septiembre 2012, 04:06 am »

Este codigo quisiera pasarlo a c++ para probarlo pero no pude , quisiera ayuda si pueden hecharle un vistazo :)

http://forum.ragezone.com/f144/changing-crc32-code-875483/

Original en vb
Código:
Option Explicit On
Option Strict On

<System.Diagnostics.DebuggerStepThrough()> _
Friend Class CRC32

    Private crc32Table() As Integer
    Private Const BUFFER_SIZE As Integer = 1024I

    Friend Function GetCrc32(ByRef stream As System.IO.FileStream) As Integer
        Dim crc32Result As Integer = &HFFFFFFFF

        Dim buffer(BUFFER_SIZE) As Byte
        Dim readSize As Integer = BUFFER_SIZE
        Dim count As Integer = stream.Read(buffer, 0I, readSize)
        Dim i As Integer
        Dim iLookup As Integer

        Do While (count > 0I)
            For i = 0I To count - 1I
                iLookup = (crc32Result And &HFF) Xor buffer(i)
                crc32Result = ((crc32Result And &HFFFFFF00) \ &H100) And &HFFFFFF   ' nasty shr 8 with vb :/
                crc32Result = crc32Result Xor crc32Table(iLookup)
            Next i
            count = stream.Read(buffer, 0I, readSize)
        Loop
        Return Not (crc32Result)
    End Function

    Friend Function GetCrc32String(ByRef stream As System.IO.FileStream) As String
        Return String.Format("{0:X8}", GetCrc32(stream))
    End Function

    Friend Sub New()
        ' This is the official polynomial used by CRC32 in PKZip.
        ' Often the polynomial is shown reversed (04C11DB7).
        Dim dwPolynomial As Integer = &HEDB88320
        Dim i, j As Integer

        ReDim crc32Table(256I)
        Dim dwCrc As Integer

        For i = 0I To 255I
            dwCrc = i
            For j = 8I To 1I Step -1I
                If (dwCrc And 1I) > 0I Then
                    dwCrc = ((dwCrc And &HFFFFFFFE) \ 2I) And &H7FFFFFFF
                    dwCrc = dwCrc Xor dwPolynomial
                Else
                    dwCrc = ((dwCrc And &HFFFFFFFE) \ 2I) And &H7FFFFFFF
                End If
            Next j
            crc32Table(i) = dwCrc
        Next i
    End Sub
End Class

Lo que pasea c++
Código:
#include <fstream>
#include <iostream>
using namespace std;
const int BUFFERSIZE1 = 1024;

class CRC32
{
private:

int crc32Table[];
    //const int BUFFERSIZE1 = 1024;

    int GetCrc32(ifstream& stream)
    {
        
int crc32Result = 0xFFFFFFFF;

BYTE buffer[BUFFERSIZE1];
int readSize = BUFFERSIZE1;
//stream.read( (char*)buffer, readSize);
int count = stream.get();
int i;
int iLookup;

        while (count > 0)
{
for(i = 0; i<= count - 1;i++)
{
                iLookup = (crc32Result & 0xFF) ^ buffer[i];
                crc32Result = 5; //((crc32Result & 0xFFFFFF00) \ 0x100) & 0xFFFFFF;/*1*/
                crc32Result = crc32Result ^ crc32Table[iLookup];
            }

//stream.read(buffer, readSize);
            count = stream.get();
        }
        return !(crc32Result);
}

    const char* GetCrc32String(ofstream& stream)
{
        //Return String.Format("{0:X8}", GetCrc32(stream))
return NULL;
    }

    void New(){
        
//' This is the official polynomial used by CRC32 in PKZip.
        //' Often the polynomial is shown reversed (04C11DB7).
        int dwPolynomial = 0xEDB88320;
        int i, j;

        int crc32Table[256];
        int dwCrc;

        for(i = 0; i<256;i++)
{
            dwCrc = i;
for(j = 8; j>-1; j--)
{
if((dwCrc & 1) > 0)
{
                    dwCrc = 5;//((dwCrc & 0xFFFFFFFE) \ 2) & 0x7FFFFFFF;/*2*/
                    dwCrc = dwCrc ^ dwPolynomial;
}
                else
{
                    dwCrc = 5; //((dwCrc & 0xFFFFFFFE) \ 2) & 0x7FFFFFFF;/*3*/
                }
            }
            crc32Table[i] = dwCrc;
        }
    }
};

las lineas que marque con /*numero*/ son las que el compilador me dice "illegal escape sequence", me ayudarian?





En línea

avesudra


Desconectado Desconectado

Mensajes: 724


Intentando ser mejor cada día :)


Ver Perfil
Re: me ayudan con vb a c++
« Respuesta #1 en: 16 Septiembre 2012, 04:12 am »

Error de operador , en c++ por lo menos no se en otros se usa el fordward slash '/' sin comillas para dividir. Asi que cambia todos los backslash '\' por '/' sin las comillas.

¡Un saludo y bienvenido al foro!


« Última modificación: 16 Septiembre 2012, 04:19 am por avesudra » En línea

Regístrate en
hacktiger

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Re: me ayudan con vb a c++
« Respuesta #2 en: 16 Septiembre 2012, 04:30 am »

ahhhh era eso  :P
ahora lo cambie para mejor, aver asi

Código:

#include <fstream>
#include <iostream>
using namespace std;
const int BUFFERSIZE1 = 1024;

class CRC32
{
private:

int crc32Table[];
    //const int BUFFERSIZE1 = 1024;
static char result[400];

public:
    int GetCrc32(ifstream& stream)
{
       
int crc32Result = 0xFFFFFFFF;

BYTE buffer[BUFFERSIZE1];
int readSize = BUFFERSIZE1;
//stream.read( (char*)buffer, readSize);
int count = stream.get();
int i;
int iLookup;

        while (count > 0)
{
for(i = 0; i<= count - 1;i++)
{
                iLookup = (crc32Result & 0xFF) ^ buffer[i];
                crc32Result = ((crc32Result & 0xFFFFFF00) / 0x100) & 0xFFFFFF;// nasty shr 8 with vb :/
                crc32Result = crc32Result ^ crc32Table[iLookup];
            }

//stream.read(buffer, readSize);
            count = stream.get();
        }
        return !(crc32Result);
}

    const char* GetCrc32String(ifstream& stream)
{
        //Return String.Format("{0:X8}", GetCrc32(stream))
result[0]=0;
sprintf(result, "0x%X",GetCrc32(stream));
return result;
    }

    void New()
{
       
//' This is the official polynomial used by CRC32 in PKZip.
        //' Often the polynomial is shown reversed (04C11DB7).
        int dwPolynomial = 0xEDB88320;
        int i, j;

        int crc32Table[256];
        int dwCrc;

        for(i = 0; i<256;i++)
{
            dwCrc = i;
for(j = 8; j>-1; j--)
{
if((dwCrc & 1) > 0)
{
                    dwCrc = ((dwCrc & 0xFFFFFFFE) / 2) & 0x7FFFFFFF;
                    dwCrc = dwCrc ^ dwPolynomial;
}
                else
{
                    dwCrc = ((dwCrc & 0xFFFFFFFE) / 2) & 0x7FFFFFFF;
                }
            }
            crc32Table[i] = dwCrc;
        }
    }
};
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Me ayudan?
Hacking
moiseswono 9 4,669 Último mensaje 22 Enero 2018, 02:47 am
por simorg
Ayudan a un novato?
Hacking Wireless
JazFlo 5 5,100 Último mensaje 7 Marzo 2018, 21:01 pm
por Dr. Binary
me ayudan con los scopes jsf 3.0
Java
Beginner Web 0 1,467 Último mensaje 26 Julio 2019, 12:11 pm
por Beginner Web
¿Me ayudan por favor?
Programación C/C++
Sah4 2 4,197 Último mensaje 31 Mayo 2021, 04:21 am
por Sah4
Me ayudan!! porfavor
Dudas Generales
sergiokun 2 1,879 Último mensaje 7 Septiembre 2023, 19:50 pm
por sergiokun
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines