当前位置: 首页>>代码示例>>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;未经允许,请勿转载。