类 HashingSink
java.lang.Object
com.lark.oapi.okio.ForwardingSink
com.lark.oapi.okio.HashingSink
- 所有已实现的接口:
Sink,Closeable,Flushable,AutoCloseable
A sink that computes a hash of the full stream of bytes it has accepted. To use, create an
instance with your preferred hash algorithm. Write all of the data to the sink and then call
hash() to compute the final hash value.
In this example we use HashingSink with a BufferedSink to make writing to the
sink easier.
HashingSink hashingSink = HashingSink.sha256(s);
BufferedSink bufferedSink = Okio.buffer(hashingSink);
... // Write to bufferedSink and either flush or close it.
ByteString hash = hashingSink.hash();
-
方法概要
修饰符和类型方法说明final ByteStringhash()Returns the hash of the bytes accepted thus far and resets the internal state of this sink.static HashingSinkhmacSha1(Sink sink, ByteString key) Returns a sink that uses the obsolete SHA-1 HMAC algorithm to produce 160-bit hashes.static HashingSinkhmacSha256(Sink sink, ByteString key) Returns a sink that uses the SHA-256 HMAC algorithm to produce 256-bit hashes.static HashingSinkhmacSha512(Sink sink, ByteString key) Returns a sink that uses the SHA-512 HMAC algorithm to produce 512-bit hashes.static HashingSinkReturns a sink that uses the obsolete MD5 hash algorithm to produce 128-bit hashes.static HashingSinkReturns a sink that uses the obsolete SHA-1 hash algorithm to produce 160-bit hashes.static HashingSinkReturns a sink that uses the SHA-256 hash algorithm to produce 256-bit hashes.static HashingSinkReturns a sink that uses the SHA-512 hash algorithm to produce 512-bit hashes.voidRemovesbyteCountbytes fromsourceand appends them to this.
-
方法详细资料
-
md5
Returns a sink that uses the obsolete MD5 hash algorithm to produce 128-bit hashes. -
sha1
Returns a sink that uses the obsolete SHA-1 hash algorithm to produce 160-bit hashes. -
sha256
Returns a sink that uses the SHA-256 hash algorithm to produce 256-bit hashes. -
sha512
Returns a sink that uses the SHA-512 hash algorithm to produce 512-bit hashes. -
hmacSha1
Returns a sink that uses the obsolete SHA-1 HMAC algorithm to produce 160-bit hashes. -
hmacSha256
Returns a sink that uses the SHA-256 HMAC algorithm to produce 256-bit hashes. -
hmacSha512
Returns a sink that uses the SHA-512 HMAC algorithm to produce 512-bit hashes. -
write
从接口复制的说明:SinkRemovesbyteCountbytes fromsourceand appends them to this.- 指定者:
write在接口中Sink- 覆盖:
write在类中ForwardingSink- 抛出:
IOException
-
hash
Returns the hash of the bytes accepted thus far and resets the internal state of this sink.Warning: This method is not idempotent. Each time this method is called its internal state is cleared. This starts a new hash with zero bytes accepted.
-