Skip to content

Commit 4367807

Browse files
committed
feat: publish rc v1
0 parents  commit 4367807

10 files changed

Lines changed: 1213 additions & 0 deletions

File tree

.gitignore

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# See https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
2+
3+
# compiled output
4+
dist
5+
tmp
6+
out-tsc
7+
8+
# dependencies
9+
node_modules
10+
11+
# IDEs and editors
12+
/.idea
13+
.project
14+
.classpath
15+
.c9/
16+
*.launch
17+
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
26+
27+
# misc
28+
/.sass-cache
29+
/connect.lock
30+
/coverage
31+
/libpeerconnection.log
32+
npm-debug.log
33+
yarn-error.log
34+
testem.log
35+
/typings
36+
37+
# System Files
38+
.DS_Store
39+
Thumbs.db
40+
41+
.nx/cache
42+
.nx/workspace-data
43+
44+
test-output
45+
46+
# Environment variables
47+
.env
48+
.env.local
49+
.env.development.local
50+
.env.test.local
51+
.env.production.local

.npmignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Ignore the source TypeScript files, as only compiled JS is needed in the package
2+
src/
3+
.vscode/
4+
5+
# Ignore TypeScript configuration and build tools
6+
tsconfig.json
7+
tslint.json
8+
.eslintrc
9+
.eslintignore
10+
11+
# Ignore any test files or folders
12+
__tests__/
13+
*.test.ts
14+
*.spec.ts
15+
*.test.js
16+
*.spec.js
17+
18+
# Ignore other configuration and helper files
19+
.env
20+
.gitignore
21+
.npmignore
22+
23+
# Ignore development folders and logs
24+
node_modules/
25+
dist/
26+
*.log

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["bradlc.vscode-tailwindcss"]
3+
}

.vscode/settings.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true,
4+
"editor.formatOnPaste": true,
5+
"editor.formatOnType": true,
6+
"editor.tabSize": 2,
7+
"editor.wordWrap": "on",
8+
9+
"prettier.tabWidth": 2,
10+
"prettier.useTabs": false,
11+
"prettier.semi": true,
12+
"prettier.singleQuote": true,
13+
"prettier.trailingComma": "all",
14+
"prettier.bracketSpacing": true,
15+
"prettier.bracketSameLine": false,
16+
"prettier.arrowParens": "always",
17+
"prettier.endOfLine": "lf",
18+
19+
"[typescript]": {
20+
"editor.defaultFormatter": "esbenp.prettier-vscode",
21+
"editor.codeActionsOnSave": {
22+
"source.fixAll": "explicit",
23+
"source.organizeImports": "explicit"
24+
}
25+
},
26+
"[typescriptreact]": {
27+
"editor.defaultFormatter": "esbenp.prettier-vscode",
28+
"editor.codeActionsOnSave": {
29+
"source.fixAll": "explicit",
30+
"source.organizeImports": "explicit"
31+
}
32+
},
33+
"[javascript]": {
34+
"editor.defaultFormatter": "esbenp.prettier-vscode"
35+
},
36+
"[javascriptreact]": {
37+
"editor.defaultFormatter": "esbenp.prettier-vscode"
38+
},
39+
"[json]": {
40+
"editor.defaultFormatter": "esbenp.prettier-vscode"
41+
},
42+
43+
"eslint.validate": [
44+
"javascript",
45+
"javascriptreact",
46+
"typescript",
47+
"typescriptreact"
48+
],
49+
"eslint.run": "onType",
50+
"eslint.lintTask.enable": true,
51+
52+
"typescript.updateImportsOnFileMove.enabled": "always",
53+
"javascript.updateImportsOnFileMove.enabled": "always",
54+
"editor.bracketPairColorization.enabled": true,
55+
"editor.autoClosingBrackets": "always",
56+
"editor.autoClosingQuotes": "always",
57+
"editor.guides.bracketPairs": "active",
58+
"editor.inlineSuggest.enabled": true,
59+
"typescript.preferences.importModuleSpecifier": "relative",
60+
"javascript.preferences.importModuleSpecifier": "relative"
61+
}

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# node-encryptor
2+
3+
A lightweight, production-ready Node.js utility library for modern cryptography. It provides a clean, promise-based API for symmetric encryption (AES), asymmetric encryption (RSA), hashing, HMAC, and secure comparisons.
4+
5+
---
6+
7+
## 🚀 Features
8+
9+
- **Symmetric Encryption:** AES-192-CBC with `scrypt` key derivation.
10+
- **Asymmetric Encryption:** RSA key pair generation and encryption/decryption.
11+
- **Hashing & HMAC:** SHA-256 based utilities for data integrity.
12+
- **Security First:** Uses `timingSafeEqual` for comparisons and secure random byte generation.
13+
- **TypeScript Native:** Full type definitions included.
14+
15+
---
16+
17+
## 📦 Installation
18+
19+
```bash
20+
npm install node-encryptor
21+
```
22+
23+
## 📦 Usage
24+
25+
```tsx
26+
import { Crypto } from 'node-encryptor';
27+
28+
// Symmetric Encryption
29+
const encrypted = await Crypto.cipheriv(
30+
{ message: 'Hello World' },
31+
'my-password',
32+
);
33+
const decrypted = await Crypto.decipheriv(encrypted, 'my-password');
34+
console.log(decrypted); // { message: 'Hello World' }
35+
36+
// Hashing
37+
const hash = Crypto.hash('my data');
38+
const hmac = Crypto.hmac('my data', 'secret-key');
39+
40+
// RSA Encryption
41+
const { publicKey, privateKey } = Crypto.generateRSAKeyPair();
42+
const encryptedRSA = Crypto.encryptWithPublicKey('secret message', publicKey);
43+
const decryptedRSA = Crypto.decryptWithPrivateKey(encryptedRSA, privateKey);
44+
45+
// Utilities
46+
const randomHex = Crypto.randomHexString(32);
47+
const isEqual = Crypto.safeCompare('value1', 'value2');
48+
49+
// Interfaces
50+
interface Decipheriv {
51+
salt: string;
52+
iv: string;
53+
data: string;
54+
}
55+
```

eslint.config.mts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import tseslint from "typescript-eslint";
4+
import { defineConfig } from "eslint/config";
5+
6+
export default defineConfig([
7+
{ files: ["**/*.{js,mjs,cjs,ts,mts,cts}"], plugins: { js }, extends: ["js/recommended"], languageOptions: { globals: globals.browser } },
8+
tseslint.configs.recommended,
9+
]);

package.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "node-encryptor",
3+
"version": "1.1.0",
4+
"private": false,
5+
"files": [
6+
"dist"
7+
],
8+
"publishConfig": {
9+
"access": "public"
10+
},
11+
"main": "dist/index.js",
12+
"types": "dist/index.d.ts",
13+
"exports": {
14+
".": {
15+
"import": "./dist/index.js",
16+
"require": "./dist/index.js",
17+
"types": "./dist/index.d.ts"
18+
}
19+
},
20+
"scripts": {
21+
"build": "tsc",
22+
"prepublishOnly": "npm run build"
23+
},
24+
"repository": {
25+
"type": "git",
26+
"url": "git+https://github.com/jsdev-robin/node-encryptor.git"
27+
},
28+
"keywords": [
29+
"node",
30+
"crypto",
31+
"encryption",
32+
"decryption",
33+
"hashing",
34+
"hmac",
35+
"rsa",
36+
"security",
37+
"secure",
38+
"cryptography",
39+
"crypto-utils",
40+
"nodejs"
41+
],
42+
"author": "jsdev.robin@gmail.com",
43+
"license": "ISC",
44+
"bugs": {
45+
"url": "https://github.com/jsdev-robin/node-encryptor/issues"
46+
},
47+
"homepage": "https://github.com/jsdev-robin/node-encryptor#readme",
48+
"description": "A Node.js library providing encryption, decryption, hashing, HMAC, RSA, and secure utility functions for modern applications.",
49+
"devDependencies": {
50+
"@eslint/js": "^10.0.1",
51+
"@types/node": "^25.5.0",
52+
"eslint": "^10.1.0",
53+
"globals": "^17.4.0",
54+
"jiti": "^2.6.1",
55+
"typescript": "5.2.2",
56+
"typescript-eslint": "^8.57.2"
57+
}
58+
}

0 commit comments

Comments
 (0)