类 HashingSource
java.lang.Object
com.lark.oapi.okio.ForwardingSource
com.lark.oapi.okio.HashingSource
- 所有已实现的接口:
Source,Closeable,AutoCloseable
A source that computes a hash of the full stream of bytes it has supplied. To use, create an
instance with your preferred hash algorithm. Exhaust the source by reading all of its bytes and
then call
hash() to compute the final hash value.
In this example we use HashingSource with a BufferedSource to make reading
from the source easier.
HashingSource hashingSource = HashingSource.sha256(rawSource);
BufferedSource bufferedSource = Okio.buffer(hashingSource);
... // Read all of bufferedSource.
ByteString hash = hashingSource.hash();
-
方法概要
修饰符和类型方法说明final ByteStringhash()Returns the hash of the bytes supplied thus far and resets the internal state of this source.static HashingSourcehmacSha1(Source source, ByteString key) Returns a sink that uses the obsolete SHA-1 HMAC algorithm to produce 160-bit hashes.static HashingSourcehmacSha256(Source source, ByteString key) Returns a sink that uses the SHA-256 HMAC algorithm to produce 256-bit hashes.static HashingSourceReturns a sink that uses the obsolete MD5 hash algorithm to produce 128-bit hashes.longRemoves at least 1, and up tobyteCountbytes from this and appends them tosink.static HashingSourceReturns a sink that uses the obsolete SHA-1 hash algorithm to produce 160-bit hashes.static HashingSourceReturns a sink that uses the SHA-256 hash algorithm to produce 256-bit hashes.从类继承的方法 com.lark.oapi.okio.ForwardingSource
close, delegate, timeout, toString
-
方法详细资料
-
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. -
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. -
read
从接口复制的说明:SourceRemoves at least 1, and up tobyteCountbytes from this and appends them tosink. Returns the number of bytes read, or -1 if this source is exhausted.- 指定者:
read在接口中Source- 覆盖:
read在类中ForwardingSource- 抛出:
IOException
-
hash
Returns the hash of the bytes supplied thus far and resets the internal state of this source.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 supplied.
-