Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Node.js 24.x build

on:
push:
branches: [master, feat/v3.0]
branches: [master, feat/v3.0.1]

jobs:
build:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Unixcrypt for Node.js

[![node.js build](https://github.com/markusberg/unixcrypt/actions/workflows/master.yaml/badge.svg)](https://github.com/markusberg/unixcrypt/actions/workflows/master.yaml)
[![coverage](https://markusberg.github.io/unixcrypt/badges/coverage-2.0.0.svg)](https://github.com/markusberg/unixcrypt/actions)
[![version](https://img.shields.io/npm/v/unixcrypt.svg)](https://codecov.io/github/markusberg/unixcrypt)
[![coverage](https://markusberg.github.io/unixcrypt/badges/coverage-3.0.1.svg)](https://github.com/markusberg/unixcrypt/actions)
![version](https://img.shields.io/npm/v/unixcrypt.svg)
[![license](https://img.shields.io/github/license/markusberg/unixcrypt.svg)](https://www.apache.org/licenses/LICENSE-2.0)

A Node.js module for encrypting and verifying passwords according to the SHA-256 and SHA-512 Crypt standard:
Expand All @@ -12,7 +12,7 @@ https://www.akkadia.org/drepper/SHA-crypt.txt

This package has no external dependencies. It uses the cryptographic facilities built into Node.js. Since version 2.0 this package is ESModule only. If you require CommonJS functionality, you can still use the 1.x version.

For development, there are dependencies on TypeScript, and vitest.
For development, there are dependencies on TypeScript, and Node.Js v24.

## Goals and motivation

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unixcrypt",
"version": "3.0.0",
"version": "3.0.1",
"description": "Node.js implementation of Unixcrypt, specifically SHA-256 and SHA-512",
"type": "module",
"exports": {
Expand Down
14 changes: 7 additions & 7 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ describe("Invalid inputs", () => {
// FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory

// it("Should be reduce the number of rounds if larger than 999,999,999", () => {
// const plaintext = "Plaintext password";
// const salt = "$6$rounds=1000000000$salt";
// const hash = "";
// const compute = encrypt(plaintext, salt);
// expect(compute, hash);
// expect(verify(plaintext, hash)).toBe(true);
// });
// const plaintext = "Plaintext password"
// const salt = "$6$rounds=1000000000$salt"
// const hash = ""
// const compute = encrypt(plaintext, salt)
// assert.equal(compute, hash)
// assert.equal(verify(plaintext, hash), true)
// })
})
13 changes: 5 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,11 @@ function parseSalt(salt?: string): IConf {
}

// sanity-check rounds
conf.rounds =
conf.rounds < roundsMin
? roundsMin
: conf.rounds > roundsMax
? /* istanbul ignore next */
(conf.rounds = roundsMax)
: conf.rounds
if (conf.rounds < roundsMin) {
conf.rounds = roundsMin
} else if (conf.rounds > roundsMax) {
conf.rounds = roundsMax
}

// sanity-check saltString
conf.saltString = conf.saltString.substring(0, 16)
Expand Down Expand Up @@ -247,7 +245,6 @@ function generateHash(plaintext: string, conf: IConf): string {
offset + digestSize < saltByteLength;
offset += digestSize
) {
/* istanbul ignore next */
s.set(digestDS, offset)
}

Expand Down