08-27-周三_17-09-29

This commit is contained in:
2025-08-27 17:10:05 +08:00
commit 86df397d8f
12735 changed files with 1145479 additions and 0 deletions

70
node_modules/hasha/index.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
'use strict';
var fs = require('fs');
var crypto = require('crypto');
var isStream = require('is-stream');
var Promise = require('pinkie-promise');
var hasha = module.exports = function (input, opts) {
opts = opts || {};
var outputEncoding = opts.encoding || 'hex';
if (outputEncoding === 'buffer') {
outputEncoding = undefined;
}
var hash = crypto.createHash(opts.algorithm || 'sha512');
var update = function (buf) {
var inputEncoding = typeof buf === 'string' ? 'utf8' : undefined;
hash.update(buf, inputEncoding);
};
if (Array.isArray(input)) {
input.forEach(update);
} else {
update(input);
}
return hash.digest(outputEncoding);
};
hasha.stream = function (opts) {
opts = opts || {};
var outputEncoding = opts.encoding || 'hex';
if (outputEncoding === 'buffer') {
outputEncoding = undefined;
}
var stream = crypto.createHash(opts.algorithm || 'sha512');
stream.setEncoding(outputEncoding);
return stream;
};
hasha.fromStream = function (stream, opts) {
if (!isStream(stream)) {
return Promise.reject(new TypeError('Expected a stream'));
}
opts = opts || {};
return new Promise(function (resolve, reject) {
stream
.on('error', reject)
.pipe(hasha.stream(opts))
.on('error', reject)
.on('finish', function () {
resolve(this.read());
});
});
};
hasha.fromFile = function (fp, opts) {
return hasha.fromStream(fs.createReadStream(fp), opts);
};
hasha.fromFileSync = function (fp, opts) {
return hasha(fs.readFileSync(fp), opts);
};

21
node_modules/hasha/license generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

121
node_modules/hasha/package.json generated vendored Normal file
View File

@@ -0,0 +1,121 @@
{
"_args": [
[
{
"name": "hasha",
"raw": "hasha@^2.2.0",
"rawSpec": "^2.2.0",
"scope": null,
"spec": ">=2.2.0 <3.0.0",
"type": "range"
},
"/root/gitbook/node_modules/phantomjs"
]
],
"_from": "hasha@>=2.2.0 <3.0.0",
"_id": "hasha@2.2.0",
"_inCache": true,
"_installable": true,
"_location": "/hasha",
"_nodeVersion": "4.2.4",
"_npmUser": {
"email": "sindresorhus@gmail.com",
"name": "sindresorhus"
},
"_npmVersion": "2.14.12",
"_phantomChildren": {},
"_requested": {
"name": "hasha",
"raw": "hasha@^2.2.0",
"rawSpec": "^2.2.0",
"scope": null,
"spec": ">=2.2.0 <3.0.0",
"type": "range"
},
"_requiredBy": [
"/phantomjs"
],
"_resolved": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz",
"_shasum": "78d7cbfc1e6d66303fe79837365984517b2f6ee1",
"_shrinkwrap": null,
"_spec": "hasha@^2.2.0",
"_where": "/root/gitbook/node_modules/phantomjs",
"author": {
"email": "sindresorhus@gmail.com",
"name": "Sindre Sorhus",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/hasha/issues"
},
"dependencies": {
"is-stream": "^1.0.1",
"pinkie-promise": "^2.0.0"
},
"description": "Hashing made simple. Get the hash of a buffer/string/stream/file.",
"devDependencies": {
"ava": "*",
"proxyquire": "^1.7.2",
"xo": "*"
},
"directories": {},
"dist": {
"integrity": "sha512-jZ38TU/EBiGKrmyTNNZgnvCZHNowiRI4+w/I9noMlekHTZH3KyGgvJLmhSgykeAQ9j2SYPDosM0Bg3wHfzibAQ==",
"shasum": "78d7cbfc1e6d66303fe79837365984517b2f6ee1",
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEQCIECtkqle9hE/BNgcL28c59Ksutqrs4krNkjnCXobdrJoAiAf/FF7XefJgdMs0A+BAtJykpqpF3lgbCMbEBTaraFBjQ=="
}
],
"tarball": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "5104d62d41122047a9da143fcd05e9397ff494a2",
"homepage": "https://github.com/sindresorhus/hasha",
"keywords": [
"hash",
"hashing",
"crypto",
"hex",
"base64",
"md5",
"sha1",
"sha256",
"sha512",
"sum",
"stream",
"file",
"fs",
"buffer",
"string",
"text",
"rev",
"revving",
"simple",
"easy"
],
"license": "MIT",
"maintainers": [
{
"email": "sindresorhus@gmail.com",
"name": "sindresorhus"
}
],
"name": "hasha",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/hasha.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "2.2.0"
}

120
node_modules/hasha/readme.md generated vendored Normal file
View File

@@ -0,0 +1,120 @@
<h1 align="center">
<br>
<br>
<br>
<img width="380" src="https://rawgit.com/sindresorhus/hasha/master/media/logo.svg" alt="hasha">
<br>
<br>
<br>
<br>
<br>
</h1>
> Hashing made simple. Get the hash of a buffer/string/stream/file.
[![Build Status](https://travis-ci.org/sindresorhus/hasha.svg?branch=master)](https://travis-ci.org/sindresorhus/hasha)
Convenience wrapper around the core [`crypto` Hash class](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm) with simpler API and better defaults.
## Install
```
$ npm install --save hasha
```
## Usage
```js
var hasha = require('hasha');
hasha('unicorn');
//=> 'e233b19aabc7d5e53826fb734d1222f1f0444c3a3fc67ff4af370a66e7cadd2cb24009f1bc86f0bed12ca5fcb226145ad10fc5f650f6ef0959f8aadc5a594b27'
```
```js
var hasha = require('hasha');
// hash the process input and output the hash sum
process.stdin.pipe(hasha.stream()).pipe(process.stdout);
```
```js
var hasha = require('hasha');
// get the MD5 hash of an image
hasha.fromFile('unicorn.png', {algorithm: 'md5'}).then(function (hash) {
console.log(hash);
//=> '1abcb33beeb811dca15f0ac3e47b88d9'
});
```
## API
See the Node.js [`crypto` docs](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm) for more about hashing.
### hasha(input, [options])
Returns a hash.
#### input
Type: `buffer`, `string`, `array` of `string`|`buffer`
Buffer you want to hash.
While strings are supported you should prefer buffers as they're faster to hash. Though if you already have a string you should not convert it to a buffer.
Pass an array instead of concatenating strings and/or buffers. The output is the same, but arrays do not incur the overhead of concatenation.
#### options
##### encoding
Type: `string`
Default: `hex`
Values: `hex`, `base64`, `buffer`, `binary`
Encoding of the returned hash.
##### algorithm
Type: `string`
Default: `sha512`
Values: `md5`, `sha1`, `sha256`, `sha512`, etc *([platform dependent](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm))*
*The `md5` algorithm is good for [file revving](https://github.com/sindresorhus/rev-hash), but you should never use `md5` or `sha1` for anything sensitive. [They're insecure.](http://googleonlinesecurity.blogspot.no/2014/09/gradually-sunsetting-sha-1.html)*
### hasha.stream([options])
Returns a [hash transform stream](https://nodejs.org/api/crypto.html#crypto_class_hash).
### hasha.fromStream(stream, [options])
Returns a promise that resolves to a hash.
### hasha.fromFile(filepath, [options])
Returns a promise that resolves to a hash.
### hasha.fromFileSync(filepath, [options])
Returns a hash.
## Resources
- [Hasha: A Friendly Crypto API • DailyJS](http://dailyjs.com/2015/06/12/hasha-a-friendly-crypto-api/)
## Related
- [hasha-cli](https://github.com/sindresorhus/hasha-cli) - CLI for this module
- [hash-obj](https://github.com/sindresorhus/hash-obj) - Get the hash of an object
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)