<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSecurity%2FCRC</id>
		<title>Java/Security/CRC - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSecurity%2FCRC"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Security/CRC&amp;action=history"/>
		<updated>2026-04-21T19:07:02Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Security/CRC&amp;diff=7659&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Security/CRC&amp;diff=7659&amp;oldid=prev"/>
				<updated>2010-06-01T06:49:27Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:49, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Security/CRC&amp;diff=7658&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Security/CRC&amp;diff=7658&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:45Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== CRC Demo ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import java.io.BufferedInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.security.DigestInputStream;&lt;br /&gt;
import java.security.MessageDigest;&lt;br /&gt;
import java.security.NoSuchAlgorithmException;&lt;br /&gt;
import java.security.Security;&lt;br /&gt;
import java.util.zip.CRC32;&lt;br /&gt;
class CRC extends MessageDigest {&lt;br /&gt;
  CRC32 crc;&lt;br /&gt;
  public CRC() {&lt;br /&gt;
    super(&amp;quot;CRC&amp;quot;);&lt;br /&gt;
    crc = new CRC32();&lt;br /&gt;
  }&lt;br /&gt;
  protected void engineReset() {&lt;br /&gt;
    crc.reset();&lt;br /&gt;
  }&lt;br /&gt;
  protected void engineUpdate(byte input) {&lt;br /&gt;
    crc.update(input);&lt;br /&gt;
  }&lt;br /&gt;
  protected void engineUpdate(byte[] input, int offset, int len) {&lt;br /&gt;
    crc.update(input, offset, len);&lt;br /&gt;
  }&lt;br /&gt;
  protected byte[] engineDigest() {&lt;br /&gt;
    long l = crc.getValue();&lt;br /&gt;
    byte[] bytes = new byte[4];&lt;br /&gt;
    bytes[3] = (byte) ((l &amp;amp; 0xFF000000) &amp;gt;&amp;gt; 24);&lt;br /&gt;
    bytes[2] = (byte) ((l &amp;amp; 0x00FF0000) &amp;gt;&amp;gt; 16);&lt;br /&gt;
    bytes[1] = (byte) ((l &amp;amp; 0x0000FF00) &amp;gt;&amp;gt; 8);&lt;br /&gt;
    bytes[0] = (byte) ((l &amp;amp; 0x000000FF) &amp;gt;&amp;gt; 0);&lt;br /&gt;
    return bytes;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class CRCTest {&lt;br /&gt;
  static private String hexDigit(byte x) {&lt;br /&gt;
    StringBuffer sb = new StringBuffer();&lt;br /&gt;
    char c;&lt;br /&gt;
    // First nibble&lt;br /&gt;
    c = (char) ((x &amp;gt;&amp;gt; 4) &amp;amp; 0xf);&lt;br /&gt;
    if (c &amp;gt; 9) {&lt;br /&gt;
      c = (char) ((c - 10) + &amp;quot;a&amp;quot;);&lt;br /&gt;
    } else {&lt;br /&gt;
      c = (char) (c + &amp;quot;0&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    sb.append(c);&lt;br /&gt;
    // Second nibble&lt;br /&gt;
    c = (char) (x &amp;amp; 0xf);&lt;br /&gt;
    if (c &amp;gt; 9) {&lt;br /&gt;
      c = (char) ((c - 10) + &amp;quot;a&amp;quot;);&lt;br /&gt;
    } else {&lt;br /&gt;
      c = (char) (c + &amp;quot;0&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    sb.append(c);&lt;br /&gt;
    return sb.toString();&lt;br /&gt;
  }&lt;br /&gt;
  static private String computeDigest(MessageDigest algorithm, String filename) {&lt;br /&gt;
    String returnValue = &amp;quot;&amp;quot;;&lt;br /&gt;
    try {&lt;br /&gt;
      algorithm.reset();&lt;br /&gt;
      FileInputStream fis = new FileInputStream(filename);&lt;br /&gt;
      BufferedInputStream bis = new BufferedInputStream(fis);&lt;br /&gt;
      DigestInputStream dis = new DigestInputStream(bis, algorithm);&lt;br /&gt;
      int ch;&lt;br /&gt;
      while ((ch = dis.read()) != -1)&lt;br /&gt;
        ;&lt;br /&gt;
      StringBuffer hexString = new StringBuffer();&lt;br /&gt;
      byte digest[] = algorithm.digest();&lt;br /&gt;
      int digestLength = digest.length;&lt;br /&gt;
      for (int i = 0; i &amp;lt; digestLength; i++) {&lt;br /&gt;
        hexString.append(hexDigit(digest[i]));&lt;br /&gt;
        hexString.append(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      returnValue = hexString.toString();&lt;br /&gt;
    } catch (IOException e) {&lt;br /&gt;
      System.err.println(&amp;quot;Error generating digest for: &amp;quot; + filename);&lt;br /&gt;
    }&lt;br /&gt;
    return returnValue;&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    MessageDigest algorithm = null;&lt;br /&gt;
    Security.addProvider(new MyProvider());&lt;br /&gt;
    try {&lt;br /&gt;
      algorithm = MessageDigest.getInstance(&amp;quot;CRC32&amp;quot;);&lt;br /&gt;
    } catch (NoSuchAlgorithmException e) {&lt;br /&gt;
      System.err.println(&amp;quot;Invalid algorithm&amp;quot;);&lt;br /&gt;
      System.exit(-1);&lt;br /&gt;
    }&lt;br /&gt;
    int argsLength = args.length;&lt;br /&gt;
    for (int i = 0; i &amp;lt; argsLength; i++) {&lt;br /&gt;
      String digest = computeDigest(algorithm, args[i]);&lt;br /&gt;
      System.out.println(args[i] + &amp;quot; : &amp;quot; + digest);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>