Skip to content

Commit

Permalink
RfR?
Browse files Browse the repository at this point in the history
  • Loading branch information
angeldollface committed May 14, 2024
1 parent a4a0d4b commit 5f79d10
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 66 deletions.
79 changes: 20 additions & 59 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,13 @@

## ABOUT :books:

Roughly a year ago, I implemented my own algorithm to check the strength of a password in Dart. *Vulcheck* is my port of this package to Node.js. *Vulcheck* is a combination of the words *Vul*nerability and *Check*er. You can find the original algorithm [here](https://github.com/angeldollface/securitycheck). Enjoy! :heart_on_fire:
Roughly a year ago, I implemented my own algorithm to check the strength of a password in Dart. *Vulcheck* is my port of this package to Typescript. *Vulcheck* is a combination of the words *Vul*nerability and *Check*er. You can find the original algorithm [here](https://github.com/angeldollface/securitycheck). Enjoy! :heart_on_fire:

## USAGE :hammer:

## The Algorithm

The algorithm measures the distance between neighbouring characters. If the two characters being compared are of a different type, then the score is increased. If not, it is diminished. If two characters are compared and the distance is large, then the score is increased. At the end everything is totalled up.

### Use *Vulcheck* in a Node.js project

To use *Vulcheck* in a Node.js project, run this command in your project's root directory:

```bash
$ npm install --save-dev vulcheck
```
## THE ALGORTHM :abacus:

Be sure to also add the `"type":"module"` flag to your project's manifest, `package.json`.
The algorithm measures the distance between neighbouring characters. If the two characters being compared are of a different type, then the score is increased. If not, it is diminished. If two characters are compared and the distance is large, then the score is increased. Finally, all the distances are tallied and summed.

### Use *Vulcheck* in a Node.js project with Typescript

Add a file called `vulcheck.d.ts` to your project and put the following code inside it:

```Typescript
declare module 'vulcheck';
```
## USAGE :hammer:

### APIs

Expand All @@ -47,53 +29,24 @@ declare module 'vulcheck';
- `passwordStrength(password)`: Returns a score that says how secure your password is.
- `isSecure(password)`: Returns a boolean telling you if your password is secure or not. If the score is larger than eight, then it will return `true`.
- `generatePassword(length)`: Returns a password as a string of the length supplied.
- `testAll()`: Tests all of the above.

### Example

Here's a small example:

- 1.) Initialize a new Node.js project with the following command in a directory of your choosing:

```bash
$ npm init -y
```

- 2.) Install *Vulcheck*:

```bash
$ npm install --save-dev vulcheck
```
- 1.) Create a new Typescript file.
- 2.) Import *Vulcheck* from Deno's module repository:

- 3.) Be sure to add this line to your project's `package.json`:

```JSON
"type":"module",
```Typescript
import * as vulcheck from 'https://deno.land/x/zeppo/mod.ts';
```

- 4.) Create your `index.js` and put the following code inside it:
- 3.) You can now use any of the function signatures above by prepending `vulcheck.`:

```js
// index.js
import * as vulcheck from 'vulcheck';

function main(){
var pwd = '1969HoglinSteak';
console.log(vulcheck.isSecure(pwd).toString());
}

main();
```

- 5.) Run the project:
- 4.) You can then run the Typescript file with Deno using this command:

```bash
$ node .
deno run your_script.ts
```

- 6.) This should print `false` to the console. :wink:
- 7.) Optional: If you're not sure how to use this project, check out the example project.

## CHANGELOG :black_nib:

### Version 1.0.0
Expand Down Expand Up @@ -141,7 +94,15 @@ $ node .
- Updated `export` statement.
- Updated documentation for Typescript.

### Version 1.9.0

- Rewrote the project in Typescript.
- Migrated the project from Node.js to Deno.
- Removed the `testAll` function.
- Added unit tests for Deno.
- Relicensed the project under the [DSL v1](https://github.com/angeldollface/doll-software-license).

## NOTE :scroll:

- *Vulcheck :lock: :ribbon:* by Alexander Abraham :black_heart: a.k.a. *"Angel Dollface" :dolls: :ribbon:*
- Licensed under the MIT license.
- Licensed under the DSL v1.
13 changes: 6 additions & 7 deletions src/vulcheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Licensed under the DSL v1.
'use strict';

// This method returns the position of a
// given character as an vareger.
// given character as an integer.
export function getCharPositon(character: string): number {
let result: number = 0;
const labvar: string = character.toLowerCase();
Expand All @@ -25,13 +25,13 @@ export function getCharPositon(character: string): number {
}

// This method returns the space between two characters
// as an vareger.
// as an integer.
export function getCharSpace(characterOne: string, characterTwo: string): number {
return getCharPositon(characterTwo) - getCharPositon(characterOne);
}

// This method returns the space between two numbers
// as an vareger.
// as an integer.
export function getNumberSpace(numberOne: number, numberTwo: number): number {
return numberTwo - numberOne;
}
Expand Down Expand Up @@ -62,8 +62,7 @@ export function isInt(expr: string): boolean{
}

// This method returns the strength
// of a password on a scale from
// one to ten as an vareger.
// of a password on a scale as an integer.
export function passwordStrength(
password: string,
securityWeight: number,
Expand Down Expand Up @@ -131,7 +130,7 @@ export function isSecure(
}

/// This method generates a password of
/// the length specified and returnss it.
/// the length specified and returns it.
export function generatePassword(length: number) {
const alphabet: Array<string> = 'abcdefghijklmnopqrstuvwxyz1234567890@_;.:'.split('');
const result: Array<string> = [];
Expand All @@ -155,4 +154,4 @@ export default {
passwordStrength,
isSecure,
generatePassword,
};
};

0 comments on commit 5f79d10

Please sign in to comment.