@lcap/nasl-utils
Advanced tools
Comparing version 3.9.0-beta.46 to 3.9.0-beta.47
/** | ||
* | ||
* @param 文件内容 content | ||
* @returns cyrb64 弱 hash,取前 8 位 | ||
* @returns MD5 hash值8位 | ||
*/ | ||
export declare const genHash: (str: string) => string; | ||
export default genHash; | ||
export declare function genHash(content: string): string; | ||
//# sourceMappingURL=hash.d.ts.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.genHash = void 0; | ||
// cyrb53 (c) 2018 bryc (github.com/bryc). License: Public domain. Attribution appreciated. | ||
// A fast and simple 64-bit (or 53-bit) string hash function with decent collision resistance. | ||
// Largely inspired by MurmurHash2/3, but with a focus on speed/simplicity. | ||
// See https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript/52171480#52171480 | ||
// https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js | ||
const cyrb64 = (str, seed = 0) => { | ||
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed; | ||
for (let i = 0, ch; i < str.length; i++) { | ||
ch = str.charCodeAt(i); | ||
h1 = Math.imul(h1 ^ ch, 2654435761); | ||
h2 = Math.imul(h2 ^ ch, 1597334677); | ||
} | ||
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507); | ||
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909); | ||
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507); | ||
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909); | ||
// For a single 53-bit numeric return value we could return | ||
// 4294967296 * (2097151 & h2) + (h1 >>> 0); | ||
// but we instead return the full 64-bit value: | ||
return [h2 >>> 0, h1 >>> 0]; | ||
}; | ||
// An improved, *insecure* 64-bit hash that's short, fast, and has no dependencies. | ||
// Output is always 14 characters. | ||
const cyrb64Hash = (str, seed = 0) => { | ||
const [h2, h1] = cyrb64(str, seed); | ||
return h2.toString(36).padStart(7, '0') + h1.toString(36).padStart(7, '0'); | ||
}; | ||
const crypto = __importStar(require("crypto")); | ||
/** | ||
* | ||
* @param 文件内容 content | ||
* @returns cyrb64 弱 hash,取前 8 位 | ||
* @returns MD5 hash值8位 | ||
*/ | ||
const genHash = (str) => cyrb64Hash(str, 0).slice(0, 8); | ||
function genHash(content) { | ||
const hash = crypto.createHash('md5').update(content, 'utf8').digest('hex'); | ||
return hash.slice(0, 8); | ||
} | ||
exports.genHash = genHash; | ||
exports.default = exports.genHash; | ||
//# sourceMappingURL=hash.js.map |
{ | ||
"name": "@lcap/nasl-utils", | ||
"description": "NetEase Application Specific Language", | ||
"version": "3.9.0-beta.46", | ||
"version": "3.9.0-beta.47", | ||
"author": "Forrest <rainforest92@126.com>", | ||
@@ -21,8 +21,8 @@ "main": "./out", | ||
"typescript": "5.4.4", | ||
"@lcap/nasl-tsconfig": "1.0.1", | ||
"@lcap/nasl-test-toolkit": "1.0.0" | ||
"@lcap/nasl-test-toolkit": "1.0.0", | ||
"@lcap/nasl-tsconfig": "1.0.1" | ||
}, | ||
"dependencies": { | ||
"uuid": "8.3.2", | ||
"@lcap/nasl-types": "3.9.0-beta.46" | ||
"@lcap/nasl-types": "3.9.0-beta.47" | ||
}, | ||
@@ -29,0 +29,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125443
2020
+ Added@lcap/nasl-types@3.9.0-beta.47(transitive)
- Removed@lcap/nasl-types@3.9.0-beta.46(transitive)