Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CRC Computation using algorithm

 
kirrz nar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a file titled input.txt. The first line of the file has a divisor and the second line has the message. I have to write a single Java class that accepts a single command line argument of an integer - and when it is 0 it has to compute the CRC code implementing the CRC algorithm.
Once the checksum computation is completed, the output should be the message with the CRC code.

I know how this works on paper, I just can't seem to put it into Java! What is the algorithm? What is checksum? Help!!!
 
Henry Wong
author
Marshal
Pie
Posts: 20902
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know how this works on paper, I just can't seem to put it into Java! What is the algorithm? What is checksum? Help!!!


You are trying to do too much, do something small that is part of the program. For example...

How about writing a method that just opens the file, and reads the input into some location?

How about writing a method that does one iteration of the CRC? How about building on that method, and write a method that feed a whole array of characters into it?

Once you have these pieces, then the overall program is just putting these two pieces together, with some printing code.

Henry
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know how it works on paper... but it sounds like you don't know what CRC is and how it works. Do a Google search, I'm sure you can find info on the CRC algorithm. I think there are different variants of the algorithm, so you might have to find out exactly which variant you need.

Or, have a look at the API documentation of class java.util.zip.CRC32.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic