test
This commit is contained in:
20
node_modules/apache-md5/LICENSE
generated
vendored
Normal file
20
node_modules/apache-md5/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Gevorg Harutyunyan
|
||||
|
||||
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.
|
||||
43
node_modules/apache-md5/README.md
generated
vendored
Normal file
43
node_modules/apache-md5/README.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# apache-md5
|
||||
[Node.js](http://nodejs.org/) package for Apache style password encryption using md5.
|
||||
|
||||
[](https://github.com/gevorg/apache-md5/actions/workflows/build.yml)
|
||||
|
||||
## Installation
|
||||
|
||||
Via git (or downloaded tarball):
|
||||
|
||||
```bash
|
||||
$ git clone git://github.com/gevorg/apache-md5.git
|
||||
```
|
||||
Via [npm](http://npmjs.org/):
|
||||
|
||||
```bash
|
||||
$ npm install apache-md5
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
const md5 = require("apache-md5");
|
||||
|
||||
// Encrypting password using apache's md5 algorithm.
|
||||
const encryptedPassword = md5("mypass");
|
||||
|
||||
// Should print true.
|
||||
console.log(md5("mypass", encryptedPassword) == encryptedPassword);
|
||||
// Should print false.
|
||||
console.log(md5("notmypass", encryptedPassword) == encryptedPassword);
|
||||
```
|
||||
|
||||
## Running tests
|
||||
|
||||
It uses [mocha](https://mochajs.org/), so just run following command in package directory:
|
||||
|
||||
```bash
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
51
node_modules/apache-md5/package.json
generated
vendored
Normal file
51
node_modules/apache-md5/package.json
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "apache-md5",
|
||||
"description": "Node.js module for Apache style password encryption using md5.",
|
||||
"version": "1.1.8",
|
||||
"author": "Gevorg Harutyunyan (http://github.com/gevorg)",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "gevorg",
|
||||
"email": "gevorg.ha@gmail.com"
|
||||
}
|
||||
],
|
||||
"homepage": "http://github.com/gevorg/apache-md5",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/gevorg/apache-md5.git"
|
||||
},
|
||||
"main": "./src/index.js",
|
||||
"typings": "./src/apache-md5.d.ts",
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://github.com/gevorg/apache-md5/blob/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "http://github.com/gevorg/apache-md5/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.10.0",
|
||||
"eslint-plugin-node": "^11.0.0",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"mocha": "^7.0.1",
|
||||
"prettier": "^1.19.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"pretest": "eslint --ignore-path .gitignore ."
|
||||
},
|
||||
"keywords": [
|
||||
"apache",
|
||||
"md5",
|
||||
"password",
|
||||
"htpasswd"
|
||||
]
|
||||
}
|
||||
4
node_modules/apache-md5/src/apache-md5.d.ts
generated
vendored
Normal file
4
node_modules/apache-md5/src/apache-md5.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare function aprMd5(password: string, salt?: string): string;
|
||||
|
||||
export default aprMd5;
|
||||
|
||||
148
node_modules/apache-md5/src/index.js
generated
vendored
Normal file
148
node_modules/apache-md5/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
"use strict";
|
||||
|
||||
// Crypto module import.
|
||||
const crypto = require("crypto");
|
||||
|
||||
// Hash generation string.
|
||||
const itoa64 =
|
||||
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
// To 64 bit version.
|
||||
function to64(index, count) {
|
||||
let result = "";
|
||||
|
||||
while (--count >= 0) {
|
||||
// Result char count.
|
||||
result += itoa64[index & 63]; // Get corresponding char.
|
||||
index = index >> 6; // Move to next one.
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Returns salt.
|
||||
function getSalt(inputSalt) {
|
||||
let salt = "";
|
||||
|
||||
if (inputSalt) {
|
||||
// Remove $apr1$ token and extract salt.
|
||||
salt = inputSalt.split("$")[2];
|
||||
} else {
|
||||
while (salt.length < 8) {
|
||||
// Random 8 chars.
|
||||
let rchIndex = Math.floor(Math.random() * 64);
|
||||
salt += itoa64[rchIndex];
|
||||
}
|
||||
}
|
||||
|
||||
return salt;
|
||||
}
|
||||
|
||||
// Returns password.
|
||||
function getPassword(final) {
|
||||
// Encrypted pass.
|
||||
let epass = "";
|
||||
|
||||
epass += to64(
|
||||
(final.charCodeAt(0) << 16) |
|
||||
(final.charCodeAt(6) << 8) |
|
||||
final.charCodeAt(12),
|
||||
4
|
||||
);
|
||||
epass += to64(
|
||||
(final.charCodeAt(1) << 16) |
|
||||
(final.charCodeAt(7) << 8) |
|
||||
final.charCodeAt(13),
|
||||
4
|
||||
);
|
||||
epass += to64(
|
||||
(final.charCodeAt(2) << 16) |
|
||||
(final.charCodeAt(8) << 8) |
|
||||
final.charCodeAt(14),
|
||||
4
|
||||
);
|
||||
epass += to64(
|
||||
(final.charCodeAt(3) << 16) |
|
||||
(final.charCodeAt(9) << 8) |
|
||||
final.charCodeAt(15),
|
||||
4
|
||||
);
|
||||
epass += to64(
|
||||
(final.charCodeAt(4) << 16) |
|
||||
(final.charCodeAt(10) << 8) |
|
||||
final.charCodeAt(5),
|
||||
4
|
||||
);
|
||||
epass += to64(final.charCodeAt(11), 2);
|
||||
|
||||
return epass;
|
||||
}
|
||||
|
||||
// Exporting old style.
|
||||
module.exports = (password, salt) => {
|
||||
let magic = "";
|
||||
if (salt && salt.split("$")[1] === "1") {
|
||||
magic = "$1$";
|
||||
} else {
|
||||
magic = "$apr1$";
|
||||
}
|
||||
|
||||
salt = getSalt(salt);
|
||||
|
||||
let ctx = password + magic + salt;
|
||||
let final = crypto
|
||||
.createHash("md5")
|
||||
.update(password + salt + password, "ascii")
|
||||
.digest("binary");
|
||||
|
||||
for (let pl = password.length; pl > 0; pl -= 16) {
|
||||
ctx += final.substr(0, pl > 16 ? 16 : pl);
|
||||
}
|
||||
|
||||
for (let i = password.length; i; i >>= 1) {
|
||||
if (i % 2) {
|
||||
ctx += String.fromCharCode(0);
|
||||
} else {
|
||||
ctx += password.charAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
final = crypto
|
||||
.createHash("md5")
|
||||
.update(ctx, "ascii")
|
||||
.digest("binary");
|
||||
|
||||
// 1000 loop.
|
||||
for (let i = 0; i < 1000; ++i) {
|
||||
// Weird stuff.
|
||||
let ctxl = "";
|
||||
|
||||
if (i % 2) {
|
||||
ctxl += password;
|
||||
} else {
|
||||
ctxl += final.substr(0, 16);
|
||||
}
|
||||
|
||||
if (i % 3) {
|
||||
ctxl += salt;
|
||||
}
|
||||
|
||||
if (i % 7) {
|
||||
ctxl += password;
|
||||
}
|
||||
|
||||
if (i % 2) {
|
||||
ctxl += final.substr(0, 16);
|
||||
} else {
|
||||
ctxl += password;
|
||||
}
|
||||
|
||||
// Final assignment after each loop.
|
||||
final = crypto
|
||||
.createHash("md5")
|
||||
.update(ctxl, "ascii")
|
||||
.digest("binary");
|
||||
}
|
||||
|
||||
return magic + salt + "$" + getPassword(final);
|
||||
};
|
||||
Reference in New Issue
Block a user