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])。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。