renato_m Posted June 18, 2008 Report Share Posted June 18, 2008 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 Report Share Posted June 18, 2008 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 Report Share Posted June 18, 2008 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 Author Report Share Posted June 18, 2008 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 Report Share Posted June 18, 2008 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 Report Share Posted June 19, 2008 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 Report Share Posted June 19, 2008 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