Java : Adler32 con ejemplos

Adler32 (Java SE 23 & JDK 23) en Java con ejemplos.
Encontrará muestras de código para la mayoría de los métodos Adler32.

Nota :


Summary

Una clase que permite calcular la suma de comprobación Adler-32 de un flujo de datos. Una suma de comprobación Adler-32 es casi tan fiable como una CRC-32, pero se calcula con mucha mayor rapidez. (Traducción automática)

Class diagram

final byte[] b = "abcd".getBytes();
System.out.println(Arrays.toString(b)); // [97, 98, 99, 100]

final var checksum = new Adler32();

checksum.update(b);
System.out.printf("%x%n", checksum.getValue()); // 3d8018b

Constructors

Adler32 ()

Crea un nuevo objeto Adler32. (Traducción automática)

final var checksum = new Adler32();
System.out.printf("%x%n", checksum.getValue()); // 1

checksum.update(123);
System.out.printf("%x%n", checksum.getValue()); // 7c007c

Methods

long getValue ()

Devuelve el valor de la suma de comprobación. (Traducción automática)

final var b = "abcd".getBytes();
System.out.println(Arrays.toString(b)); // [97, 98, 99, 100]

final var checksum = new Adler32();

checksum.update(b);
System.out.printf("%x%n", checksum.getValue()); // 3d8018b
final var checksum = new Adler32();

checksum.update(97);
System.out.printf("%x%n", checksum.getValue()); // 620062

checksum.update(98);
System.out.printf("%x%n", checksum.getValue()); // 12600c4

checksum.update(99);
System.out.printf("%x%n", checksum.getValue()); // 24d0127

checksum.update(100);
System.out.printf("%x%n", checksum.getValue()); // 3d8018b

void reset ()

Restablece la suma de comprobación al valor inicial. (Traducción automática)

final var checksum = new Adler32();
System.out.printf("%x%n", checksum.getValue()); // 1

checksum.update("abcd".getBytes());
System.out.printf("%x%n", checksum.getValue()); // 3d8018b

checksum.reset();
System.out.printf("%x%n", checksum.getValue()); // 1

void update (byte[] b, int off, int len)

Actualiza la suma de comprobación con la matriz de bytes especificada. (Traducción automática)

final var b = "abcdXYZ".getBytes();
System.out.println(Arrays.toString(b)); // [97, 98, 99, 100, 88, 89, 90]

final var checksum = new Adler32();

checksum.update(b, 0, 4);
System.out.printf("%x%n", checksum.getValue()); // 3d8018b

checksum.reset();
checksum.update(b, 4, 3);
System.out.printf("%x%n", checksum.getValue()); // 217010c
final var checksum = new Adler32();

checksum.update("abcd".getBytes());
System.out.printf("%x%n", checksum.getValue()); // 3d8018b

checksum.reset();
checksum.update("XYZ".getBytes());
System.out.printf("%x%n", checksum.getValue()); // 217010c

void update (int b)

Actualiza la suma de comprobación con el byte especificado (los ocho bits inferiores del argumento b). (Traducción automática)

final var b = "abcd".getBytes();
System.out.println(Arrays.toString(b)); // [97, 98, 99, 100]

final var checksum = new Adler32();

checksum.update(b);
System.out.printf("%x%n", checksum.getValue()); // 3d8018b
final var checksum = new Adler32();

checksum.update(97);
System.out.printf("%x%n", checksum.getValue()); // 620062

checksum.update(98);
System.out.printf("%x%n", checksum.getValue()); // 12600c4

checksum.update(99);
System.out.printf("%x%n", checksum.getValue()); // 24d0127

checksum.update(100);
System.out.printf("%x%n", checksum.getValue()); // 3d8018b

void update (ByteBuffer buffer)

Actualiza la suma de comprobación con los bytes del búfer especificado. (Traducción automática)

final var buffer = ByteBuffer.wrap("abcd".getBytes());
System.out.println(buffer); // java.nio.HeapByteBuffer[pos=0 lim=4 cap=4]

final var checksum = new Adler32();

checksum.update(buffer);
System.out.printf("%x%n", checksum.getValue()); // 3d8018b

System.out.println(buffer); // java.nio.HeapByteBuffer[pos=4 lim=4 cap=4]

Methods declared in Checksum

update

Consulte el siguiente enlace.


Related posts

To top of page