53 lines
1.6 KiB
Java
53 lines
1.6 KiB
Java
|
package com.google.common.hash;
|
||
|
|
||
|
import com.google.common.base.Preconditions;
|
||
|
import java.io.FilterInputStream;
|
||
|
import java.io.IOException;
|
||
|
import java.io.InputStream;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class HashingInputStream extends FilterInputStream {
|
||
|
private final Hasher hasher;
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public final void mark(int i) {
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public final boolean markSupported() {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public HashingInputStream(HashFunction hashFunction, InputStream inputStream) {
|
||
|
super((InputStream) Preconditions.checkNotNull(inputStream));
|
||
|
this.hasher = (Hasher) Preconditions.checkNotNull(hashFunction.newHasher());
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public final int read() throws IOException {
|
||
|
int read = ((FilterInputStream) this).in.read();
|
||
|
if (read != -1) {
|
||
|
this.hasher.putByte((byte) read);
|
||
|
}
|
||
|
return read;
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public final int read(byte[] bArr, int i, int i2) throws IOException {
|
||
|
int read = ((FilterInputStream) this).in.read(bArr, i, i2);
|
||
|
if (read != -1) {
|
||
|
this.hasher.putBytes(bArr, i, read);
|
||
|
}
|
||
|
return read;
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public final void reset() throws IOException {
|
||
|
throw new IOException("reset not supported");
|
||
|
}
|
||
|
|
||
|
public final HashCode hash() {
|
||
|
return this.hasher.hash();
|
||
|
}
|
||
|
}
|