hash.copy([options])
添加于:v13.1.0
参数
options
<Object> new stream.Transform([options])- 返回: <Hash>
创建一个新的 Hash
对象,其中包含当前 Hash
对象的内部状态的深层副本。
可选的options
参数控制流行为。对于 'shake256'
等 XOF 哈希函数,outputLength
选项可用于指定所需的输出长度(以字节为单位)。
如果在调用
方法后尝试复制 hash.digest()
Hash
对象,则会引发错误。
// Calculate a rolling hash. const { createHash } = await import('node:crypto'); const hash = createHash('sha256'); hash.update('one'); console.log(hash.copy().digest('hex')); hash.update('two'); console.log(hash.copy().digest('hex')); hash.update('three'); console.log(hash.copy().digest('hex')); // Etc.
// Calculate a rolling hash. const { createHash, } = require('node:crypto'); const hash = createHash('sha256'); hash.update('one'); console.log(hash.copy().digest('hex')); hash.update('two'); console.log(hash.copy().digest('hex')); hash.update('three'); console.log(hash.copy().digest('hex')); // Etc.
相关用法
- Node.js Hash用法及代码示例
- Node.js Http2ServerResponse.finished用法及代码示例
- Node.js Http2Stream close用法及代码示例
- Node.js Http2Session stream用法及代码示例
- Node.js Http2ServerResponse.getHeaderNames()用法及代码示例
- Node.js Http2Session.ping([payload, ]callback)用法及代码示例
- Node.js Http2ServerResponse.statusMessage用法及代码示例
- Node.js Http2ServerResponse.writableEnded用法及代码示例
- Node.js Http2Session timeout用法及代码示例
- Node.js Http2ServerRequest.stream用法及代码示例
- Node.js Http2ServerResponse.setHeader()用法及代码示例
- Node.js Http2ServerRequest.method用法及代码示例
- Node.js Http2ServerResponse.getHeader()用法及代码示例
- Node.js Http2Stream Headers用法及代码示例
- Node.js Http2ServerResponse.addTrailers()用法及代码示例
- Node.js Http2ServerRequest.url用法及代码示例
- Node.js Hmac用法及代码示例
- Node.js Http2ServerResponse.setTimeout()用法及代码示例
- Node.js Http2ServerRequest.complete用法及代码示例
- Node.js Http2ServerResponse.stream用法及代码示例
- Node.js Http2Stream.setTimeout(msecs, callback)用法及代码示例
- Node.js Http2ServerRequest.destroy()用法及代码示例
- Node.js Http2ServerResponse.removeHeader()用法及代码示例
- Node.js Http2Stream Response用法及代码示例
- Node.js Http2ServerResponse.hasHeader()用法及代码示例
注:本文由纯净天空筛选整理自nodejs.org大神的英文原创作品 Hash.copy([options])。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。