CRC-32: Difference between revisions

Content added Content deleted
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
Line 1,197: Line 1,197:


=={{header|Java}}==
=={{header|Java}}==
<syntaxhighlight lang=Java>import java.util.zip.* ;
<syntaxhighlight lang=Java>
import java.util.zip.CRC32;

</syntaxhighlight>
public class CRCMaker {
<syntaxhighlight lang=Java>
public static void main( String[ ] args ) {
public static void main(String[] args) throws IOException {
String toBeEncoded = new String( "The quick brown fox jumps over the lazy dog" ) ;
String string = "The quick brown fox jumps over the lazy dog";
CRC32 myCRC = new CRC32( ) ;
CRC32 crc = new CRC32();
myCRC.update( toBeEncoded.getBytes( ) ) ;
crc.update(string.getBytes());
System.out.println( "The CRC-32 value is : " + Long.toHexString( myCRC.getValue( ) ) + " !" ) ;
System.out.printf("%x", crc.getValue());
}
}
}</syntaxhighlight>
</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>The CRC-32 value is : 414fa339 !</pre>
414fa339
</pre>


=={{header|JavaScript}}==
=={{header|JavaScript}}==