renato_m Posted June 18, 2008 at 01:59 PM Report Share #191916 Posted June 18, 2008 at 01:59 PM Boa tarde pessoal!! A questao é a seguinte!! Tenho uma mensagem de 12bits que preciso validar com um CRC de 4 bits... logo a mensagem que vou receber é de 16bits(12mensagem original+4CRC) Alguem sabe como implementar em JAVA este CRC?? Precisava disso para ontem ? Obrigado desde já Link to comment Share on other sites More sharing options...
magician Posted June 18, 2008 at 02:06 PM Report Share #191921 Posted June 18, 2008 at 02:06 PM http://java.sun.com/javase/6/docs/api/java/util/zip/CRC32.html O java tem uma API para CRC Basta leres o Stream do ficheiro e enviar para o update do CRC depois de teres todo o ficheiro lido basta fazer getValue ao CRC ele retorna o numero para validar o ficheiro. Depois é juntar o numero ao ficheiro. I haven’t lost my mind; it’s backed up on DVD somewhere! Link to comment Share on other sites More sharing options...
magician Posted June 18, 2008 at 02:10 PM Report Share #191925 Posted June 18, 2008 at 02:10 PM Dá uma olhadela neste código é uma implementação diferente um inputStream que faz logo o CRC http://www.javafaq.nu/java-example-code-230.html I haven’t lost my mind; it’s backed up on DVD somewhere! Link to comment Share on other sites More sharing options...
renato_m Posted June 18, 2008 at 02:14 PM Author Report Share #191926 Posted June 18, 2008 at 02:14 PM mas o que eu tenho sao 16bits??? será k isso dá na mxm?? Link to comment Share on other sites More sharing options...
magician Posted June 18, 2008 at 03:03 PM Report Share #191934 Posted June 18, 2008 at 03:03 PM Acho que não :S Sendo assim tens duas opções ou mudar o CRC 32 ou então tens de implementar o de 16 Qualquer coisa tipo isto http://www.cs.princeton.edu/introcs/51data/CRC16.java.html I haven’t lost my mind; it’s backed up on DVD somewhere! Link to comment Share on other sites More sharing options...
Knitter Posted June 19, 2008 at 12:26 AM Report Share #192082 Posted June 19, 2008 at 12:26 AM Se poderes usar bibliotecas externas experimenta esta: http://www.jonelo.de/java/jacksum/, tens implementações de mais algoritmos do que vais precisar, mas é simples e rápida de usar. www.sergiolopes.eu Link to comment Share on other sites More sharing options...
Sergiosaturn Posted June 19, 2008 at 01:19 PM Report Share #192160 Posted June 19, 2008 at 01:19 PM olha vai a net ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now