當前位置: 首頁>>代碼示例>>Java>>正文


Java Adler32.update方法代碼示例

本文整理匯總了Java中java.util.zip.Adler32.update方法的典型用法代碼示例。如果您正苦於以下問題:Java Adler32.update方法的具體用法?Java Adler32.update怎麽用?Java Adler32.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.zip.Adler32的用法示例。


在下文中一共展示了Adler32.update方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: a

import java.util.zip.Adler32; //導入方法依賴的package包/類
private static int a(String str, int i) {
    if (TextUtils.isEmpty(str)) {
        z.b();
        return 0;
    }
    try {
        return Integer.valueOf(str).intValue();
    } catch (Exception e) {
        z.d();
        Adler32 adler32 = new Adler32();
        adler32.update(str.getBytes());
        int value = (int) adler32.getValue();
        if (value < 0) {
            value = Math.abs(value);
        }
        value += 13889152 * i;
        return value < 0 ? Math.abs(value) : value;
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:m.java

示例2: updateChecksum

import java.util.zip.Adler32; //導入方法依賴的package包/類
public static void updateChecksum(ByteBuffer buffer, int size) {
    byte[] data = buffer.array();
    MessageDigest digest;
    try {
        digest = MessageDigest.getInstance("SHA-1");
    } catch (NoSuchAlgorithmException e) {
        throw new AssertionError();
    }

    digest.update(data, 32, size - 32);
    byte[] sha1 = digest.digest();
    System.arraycopy(sha1, 0, data, 12, sha1.length);

    Adler32 adler32 = new Adler32();
    adler32.update(data, 12, size - 12);
    int v = (int) adler32.getValue();
    buffer.position(8);
    buffer.putInt(v);
}
 
開發者ID:johnlee175,項目名稱:dex,代碼行數:20,代碼來源:DexFileWriter.java

示例3: updateChecksum

import java.util.zip.Adler32; //導入方法依賴的package包/類
private void updateChecksum(@Nonnull DexDataStore dataStore) throws IOException {
    Adler32 a32 = new Adler32();

    byte[] buffer = new byte[4 * 1024];
    InputStream input = dataStore.readAt(HeaderItem.CHECKSUM_DATA_START_OFFSET);
    int bytesRead = input.read(buffer);
    while (bytesRead >= 0) {
        a32.update(buffer, 0, bytesRead);
        bytesRead = input.read(buffer);
    }

    // write checksum, utilizing logic in DexWriter to write the integer value properly
    OutputStream output = dataStore.outputAt(HeaderItem.CHECKSUM_OFFSET);
    DexDataWriter.writeInt(output, (int)a32.getValue());
    output.close();
}
 
開發者ID:Miracle963,項目名稱:zjdroid,代碼行數:17,代碼來源:DexWriter.java

示例4: fixCheckSumHeader

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * �޸�dexͷ��CheckSum У����
 * @param dexBytes
 */
private static void fixCheckSumHeader(byte[] dexBytes) {
	Adler32 adler = new Adler32();
	adler.update(dexBytes, 12, dexBytes.length - 12);//��12���ļ�ĩβ����У����
	long value = adler.getValue();
	int va = (int) value;
	byte[] newcs = intToByte(va);
	//��λ��ǰ����λ��ǰ������
	byte[] recs = new byte[4];
	for (int i = 0; i < 4; i++) {
		recs[i] = newcs[newcs.length - 1 - i];
		System.out.println(Integer.toHexString(newcs[i]));
	}
	System.arraycopy(recs, 0, dexBytes, 8, 4);//Ч���븳ֵ��8-11��
	System.out.println(Long.toHexString(value));
	System.out.println();
}
 
開發者ID:tangsilian,項目名稱:SecurityPage,代碼行數:21,代碼來源:mymain.java

示例5: fixCheckSumHeader

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * 修改dex頭,CheckSum 校驗碼
 * @param dexBytes
 */
private static void fixCheckSumHeader(byte[] dexBytes) {
    Adler32 adler = new Adler32();
    adler.update(dexBytes, 12, dexBytes.length - 12);//從12到文件末尾計算校驗碼
    long value = adler.getValue();
    int va = (int) value;
    byte[] newcs = intToByte(va);
    //高位在前,低位在前掉個個
    byte[] recs = new byte[4];
    for (int i = 0; i < 4; i++) {
        recs[i] = newcs[newcs.length - 1 - i];
        System.out.println(Integer.toHexString(newcs[i]));
    }
    System.arraycopy(recs, 0, dexBytes, 8, 4);//效驗碼賦值(8-11)
    System.out.println(Long.toHexString(value));
    System.out.println();
}
 
開發者ID:DIY-green,項目名稱:AndroidStudyDemo,代碼行數:21,代碼來源:PackerUtil.java

示例6: updateChecksum

import java.util.zip.Adler32; //導入方法依賴的package包/類
private void updateChecksum( DexDataStore dataStore) throws IOException {
    Adler32 a32 = new Adler32();

    byte[] buffer = new byte[4 * 1024];
    InputStream input = dataStore.readAt(HeaderItem.CHECKSUM_DATA_START_OFFSET);
    int bytesRead = input.read(buffer);
    while (bytesRead >= 0) {
        a32.update(buffer, 0, bytesRead);
        bytesRead = input.read(buffer);
    }

    // write checksum, utilizing logic in DexWriter to write the integer value properly
    OutputStream output = dataStore.outputAt(HeaderItem.CHECKSUM_OFFSET);
    DexDataWriter.writeInt(output, (int)a32.getValue());
    output.close();
}
 
開發者ID:AndreJCL,項目名稱:JCL,代碼行數:17,代碼來源:DexWriter.java

示例7: updateChecksum

import java.util.zip.Adler32; //導入方法依賴的package包/類
private void updateChecksum(@Nonnull DexDataStore dataStore) throws IOException {
    Adler32 a32 = new Adler32();

    byte[] buffer = new byte[4 * 1024];
    InputStream input = dataStore.readAt(HeaderItem.CHECKSUM_DATA_START_OFFSET);
    int bytesRead = input.read(buffer);
    while (bytesRead >= 0) {
        a32.update(buffer, 0, bytesRead);
        bytesRead = input.read(buffer);
    }

    // write checksum, utilizing logic in DexWriter to write the integer value properly
    OutputStream output = dataStore.outputAt(HeaderItem.CHECKSUM_OFFSET);
    DexDataWriter.writeInt(output, (int) a32.getValue());
    output.close();
}
 
開發者ID:niranjan94,項目名稱:show-java,代碼行數:17,代碼來源:DexWriter.java

示例8: sendMyRuleDataToServer

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * ルール data送信
 */
public void sendMyRuleDataToServer() {
	if(ruleOptPlayer == null) ruleOptPlayer = new RuleOptions();

	CustomProperties prop = new CustomProperties();
	ruleOptPlayer.writeProperty(prop, 0);
	String strRuleTemp = prop.encode("RuleData");
	String strRuleData = NetUtil.compressString(strRuleTemp);
	log.debug("RuleData uncompressed:" + strRuleTemp.length() + " compressed:" + strRuleData.length());

	// checkサム計算
	Adler32 checksumObj = new Adler32();
	checksumObj.update(NetUtil.stringToBytes(strRuleData));
	long sChecksum = checksumObj.getValue();

	// 送信
	netPlayerClient.send("ruledata\t" + sChecksum + "\t" + strRuleData + "\n");
}
 
開發者ID:PoochyEXE,項目名稱:nullpomino,代碼行數:21,代碼來源:NetLobbyFrame.java

示例9: decompressBytes

import java.util.zip.Adler32; //導入方法依賴的package包/類
public static byte[] decompressBytes(byte[] bytesArray) throws ClientException  { 
	
	byte[] checkSumBuf = new byte[8];
	checkSumBuf[0] = bytesArray[bytesArray.length-8];
	checkSumBuf[1] = bytesArray[bytesArray.length-7];
	checkSumBuf[2] = bytesArray[bytesArray.length-6];
	checkSumBuf[3] = bytesArray[bytesArray.length-5];
	checkSumBuf[4] = bytesArray[bytesArray.length-4];
	checkSumBuf[5] = bytesArray[bytesArray.length-3];
	checkSumBuf[6] = bytesArray[bytesArray.length-2];
	checkSumBuf[7] = bytesArray[bytesArray.length-1];
	
	
	ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE / Byte.SIZE);
    buffer.put(checkSumBuf);
    buffer.flip();//need flip 
    long checkSum = buffer.getLong();
    
    Adler32 adler32 = new Adler32();
	adler32.update(bytesArray, 0, bytesArray.length-8);
	if(checkSum !=adler32.getValue())
		throw new ClientException("Data corruption detected - checksum failure. Please, try again.");
    
	return Snappy.uncompress(bytesArray, 0, bytesArray.length -8 );
}
 
開發者ID:PortfolioEffect,項目名稱:PE-HFT-Java,代碼行數:26,代碼來源:ArrayUtil.java

示例10: calculateChecksum

import java.util.zip.Adler32; //導入方法依賴的package包/類
public static long calculateChecksum(CallFrame msg, long digestSeed) {

        // TODO: this is bad
        ByteBuf payloadCopy = msg.getPayload().slice();
        byte[] payloadBytes = new byte[msg.getPayloadSize()];
        payloadCopy.readBytes(payloadBytes);

        switch (msg.getChecksumType()) {

            case Adler32:
                Adler32 f = new Adler32();
                f.update((int) digestSeed);
                f.update(payloadBytes);
                return f.getValue();
            case FarmhashFingerPrint32:
            case NoChecksum:
            case CRC32C:
            default:
                return 0;
        }

    }
 
開發者ID:uber,項目名稱:tchannel-java,代碼行數:23,代碼來源:Checksums.java

示例11: test_updateI

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * @tests java.util.zip.Adler32#update(int)
 */
public void test_updateI() {
	// test methods of java.util.zip.update(int)
	Adler32 adl = new Adler32();
	adl.update(1);
	// The value of the adl should be 131074
	assertEquals("update(int) failed to update the checksum to the correct value ",
			131074, adl.getValue());

	adl.reset();
	adl.update(Integer.MAX_VALUE);
	// System.out.print("value of adl " + adl.getValue());
	// The value of the adl should be 16777472
	assertEquals("update(max) failed to update the checksum to the correct value ",
			16777472L, adl.getValue());

	adl.reset();
	adl.update(Integer.MIN_VALUE);
	// System.out.print("value of adl " + adl.getValue());
	// The value of the adl should be 65537
	assertEquals("update(min) failed to update the checksum to the correct value ",
			65537L, adl.getValue());

}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:27,代碼來源:Adler32Test.java

示例12: sendMeta

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * One special case is a metadata message where the sizeof(data) is 0.  In
 * that case, the unencrypted message is encoded as:
 *<pre>
 *  +-------+-------+-------+-------+-------+-------+-------+-------+
 *  |       0       |      timestamp in seconds     | uninterpreted             
 *  +-------+-------+-------+-------+-------+-------+-------+-------+
 *          uninterpreted           | adler checksum of sz+data+pad |
 *  +-------+-------+-------+-------+-------+-------+-------+-------+
 *</pre>
 */
private void sendMeta() {
    byte encrypted[] = new byte[_meta.length];
    synchronized (_meta) {
        DataHelper.toLong(_meta, 0, 2, 0);
        DataHelper.toLong(_meta, 2, 4, (_context.clock().now() + 500) / 1000);
        _context.random().nextBytes(_meta, 6, 6);
        Adler32 crc = new Adler32();
        crc.update(_meta, 0, _meta.length-4);
        DataHelper.toLong(_meta, _meta.length-4, 4, crc.getValue());
        _context.aes().encrypt(_meta, 0, encrypted, 0, _sessionKey, _prevWriteEnd, 0, _meta.length);
    }
    System.arraycopy(encrypted, encrypted.length-16, _prevWriteEnd, 0, _prevWriteEnd.length);
    // perhaps this should skip the bw limiter to reduce clock skew issues?
    if (_log.shouldLog(Log.DEBUG))
        _log.debug("Sending NTCP metadata");
    _sendingMeta = true;
    _transport.getPumper().wantsWrite(this, encrypted);
    // enqueueInfoMessage(); // this often?
}
 
開發者ID:NoYouShutup,項目名稱:CryptMeme,代碼行數:31,代碼來源:NTCPConnection.java

示例13: hashCode

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * Get the content - dependent hashcode.
 */
public int hashCode()
{
  if (has == null)
    return type().kind().value();
  else
    {
      Adler32 adler = new Adler32();

      BufferedCdrOutput a = new BufferedCdrOutput();
      a.setOrb(orb);
      write_value(a);
      
      adler.update(a.buffer.toByteArray());
      adler.update(type().kind().value());
      
      return (int) adler.getValue() & Integer.MAX_VALUE;
    }
}
 
開發者ID:taciano-perez,項目名稱:JamVM-PH,代碼行數:22,代碼來源:gnuAny.java

示例14: test_getValue

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * @tests java.util.zip.Adler32#getValue()
 */
public void test_getValue() {
	// test methods of java.util.zip.getValue()
	Adler32 adl = new Adler32();
	assertEquals("GetValue should return a zero as a result of construction an object of Adler32",
			1, adl.getValue());

	adl.reset();
	adl.update(1);
	// System.out.print("value of adl"+adl.getValue());
	// The value of the adl should be 131074
	assertEquals("update(int) failed to update the checksum to the correct value ",
			131074, adl.getValue());
	adl.reset();
	assertEquals("reset failed to reset the checksum value to zero", 1, adl
			.getValue());

	adl.reset();
	adl.update(Integer.MIN_VALUE);
	// System.out.print("value of adl " + adl.getValue());
	// The value of the adl should be 65537
	assertEquals("update(min) failed to update the checksum to the correct value ",
			65537L, adl.getValue());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:27,代碼來源:Adler32Test.java

示例15: Adler32

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * @tests java.util.zip.Adler32#update(byte[])
 */
public void test_update$B() {
	// test method of java.util.zip.update(byte[])
	byte byteArray[] = { 1, 2 };
	Adler32 adl = new Adler32();
	adl.update(byteArray);
	// System.out.print("value of adl"+adl.getValue());
	// The value of the adl should be 393220
	assertEquals("update(byte[]) failed to update the checksum to the correct value ",
			393220, adl.getValue());

	adl.reset();
	byte byteEmpty[] = new byte[10000];
	adl.update(byteEmpty);
	// System.out.print("value of adl"+adl.getValue());
	// The value of the adl should be 655360001
	assertEquals("update(byte[]) failed to update the checksum to the correct value ",
			655360001L, adl.getValue());

}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:23,代碼來源:Adler32Test.java


注:本文中的java.util.zip.Adler32.update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。