@rog0x/mcp-crypto-tools 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.hashText = hashText;
7
+ exports.hmacText = hmacText;
8
+ exports.compareHashes = compareHashes;
9
+ exports.hashMultiple = hashMultiple;
10
+ const node_crypto_1 = __importDefault(require("node:crypto"));
11
+ const SUPPORTED_ALGORITHMS = ["md5", "sha1", "sha256", "sha512"];
12
+ function normalizeAlgorithm(input) {
13
+ const normalized = input.toLowerCase().replace(/-/g, "").replace("sha_", "sha");
14
+ const map = {
15
+ md5: "md5",
16
+ sha1: "sha1",
17
+ sha256: "sha256",
18
+ sha512: "sha512",
19
+ };
20
+ const result = map[normalized];
21
+ if (!result) {
22
+ throw new Error(`Unsupported algorithm: "${input}". Supported: ${SUPPORTED_ALGORITHMS.join(", ")}`);
23
+ }
24
+ return result;
25
+ }
26
+ function getCryptoName(algo) {
27
+ const map = {
28
+ md5: "md5",
29
+ sha1: "sha1",
30
+ sha256: "sha256",
31
+ sha512: "sha512",
32
+ };
33
+ return map[algo];
34
+ }
35
+ function hashText(text, algorithm, encoding = "hex") {
36
+ const algo = normalizeAlgorithm(algorithm);
37
+ const hash = node_crypto_1.default.createHash(getCryptoName(algo)).update(text, "utf-8").digest(encoding);
38
+ return {
39
+ algorithm: algo,
40
+ hash,
41
+ encoding,
42
+ input_length: text.length,
43
+ };
44
+ }
45
+ function hmacText(text, key, algorithm, encoding = "hex") {
46
+ const algo = normalizeAlgorithm(algorithm);
47
+ const hmac = node_crypto_1.default.createHmac(getCryptoName(algo), key).update(text, "utf-8").digest(encoding);
48
+ return {
49
+ algorithm: algo,
50
+ hmac,
51
+ encoding,
52
+ input_length: text.length,
53
+ };
54
+ }
55
+ function compareHashes(hash1, hash2) {
56
+ const a = hash1.toLowerCase().trim();
57
+ const b = hash2.toLowerCase().trim();
58
+ let match;
59
+ try {
60
+ match = node_crypto_1.default.timingSafeEqual(Buffer.from(a, "utf-8"), Buffer.from(b, "utf-8"));
61
+ }
62
+ catch {
63
+ match = false;
64
+ }
65
+ return { match, hash1: a, hash2: b };
66
+ }
67
+ function hashMultiple(text, encoding = "hex") {
68
+ const result = {};
69
+ for (const algo of SUPPORTED_ALGORITHMS) {
70
+ result[algo] = node_crypto_1.default.createHash(getCryptoName(algo)).update(text, "utf-8").digest(encoding);
71
+ }
72
+ return result;
73
+ }
74
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1,26 @@
1
+ interface JWTDecodeResult {
2
+ header: Record<string, unknown>;
3
+ payload: Record<string, unknown>;
4
+ signature: string;
5
+ is_expired: boolean | null;
6
+ expires_at: string | null;
7
+ issued_at: string | null;
8
+ not_before: string | null;
9
+ time_until_expiry: string | null;
10
+ warnings: string[];
11
+ }
12
+ export declare function decodeJWT(token: string): JWTDecodeResult;
13
+ export declare function checkJWTExpiry(token: string): {
14
+ is_expired: boolean | null;
15
+ expires_at: string | null;
16
+ time_until_expiry: string | null;
17
+ issued_at: string | null;
18
+ };
19
+ export declare function createUnsignedJWT(payload: Record<string, unknown>, expiresInSeconds?: number): {
20
+ token: string;
21
+ header: Record<string, unknown>;
22
+ payload: Record<string, unknown>;
23
+ warning: string;
24
+ };
25
+ export {};
26
+ //# sourceMappingURL=jwt-tools.d.ts.map
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeJWT = decodeJWT;
4
+ exports.checkJWTExpiry = checkJWTExpiry;
5
+ exports.createUnsignedJWT = createUnsignedJWT;
6
+ function base64UrlDecode(input) {
7
+ let base64 = input.replace(/-/g, "+").replace(/_/g, "/");
8
+ while (base64.length % 4 !== 0) {
9
+ base64 += "=";
10
+ }
11
+ return Buffer.from(base64, "base64").toString("utf-8");
12
+ }
13
+ function base64UrlEncode(input) {
14
+ return Buffer.from(input, "utf-8")
15
+ .toString("base64")
16
+ .replace(/\+/g, "-")
17
+ .replace(/\//g, "_")
18
+ .replace(/=+$/, "");
19
+ }
20
+ function decodeJWT(token) {
21
+ const parts = token.trim().split(".");
22
+ if (parts.length !== 3) {
23
+ throw new Error(`Invalid JWT: expected 3 parts separated by dots, got ${parts.length}`);
24
+ }
25
+ let header;
26
+ let payload;
27
+ try {
28
+ header = JSON.parse(base64UrlDecode(parts[0]));
29
+ }
30
+ catch {
31
+ throw new Error("Invalid JWT: could not decode header as JSON");
32
+ }
33
+ try {
34
+ payload = JSON.parse(base64UrlDecode(parts[1]));
35
+ }
36
+ catch {
37
+ throw new Error("Invalid JWT: could not decode payload as JSON");
38
+ }
39
+ const signature = parts[2];
40
+ const warnings = [];
41
+ // Check expiry
42
+ let isExpired = null;
43
+ let expiresAt = null;
44
+ let timeUntilExpiry = null;
45
+ if (typeof payload.exp === "number") {
46
+ const expDate = new Date(payload.exp * 1000);
47
+ expiresAt = expDate.toISOString();
48
+ const now = Date.now();
49
+ const diff = payload.exp * 1000 - now;
50
+ isExpired = diff < 0;
51
+ if (isExpired) {
52
+ const ago = Math.abs(diff);
53
+ timeUntilExpiry = `-${formatDuration(ago)} (expired)`;
54
+ warnings.push("Token is expired");
55
+ }
56
+ else {
57
+ timeUntilExpiry = formatDuration(diff);
58
+ }
59
+ }
60
+ else {
61
+ warnings.push("No expiration claim (exp) found");
62
+ }
63
+ let issuedAt = null;
64
+ if (typeof payload.iat === "number") {
65
+ issuedAt = new Date(payload.iat * 1000).toISOString();
66
+ }
67
+ let notBefore = null;
68
+ if (typeof payload.nbf === "number") {
69
+ const nbfDate = new Date(payload.nbf * 1000);
70
+ notBefore = nbfDate.toISOString();
71
+ if (nbfDate.getTime() > Date.now()) {
72
+ warnings.push("Token is not yet valid (nbf is in the future)");
73
+ }
74
+ }
75
+ if (header.alg === "none") {
76
+ warnings.push("Token uses 'none' algorithm - unsigned and insecure");
77
+ }
78
+ if (signature.length === 0) {
79
+ warnings.push("Token has an empty signature");
80
+ }
81
+ return {
82
+ header,
83
+ payload,
84
+ signature,
85
+ is_expired: isExpired,
86
+ expires_at: expiresAt,
87
+ issued_at: issuedAt,
88
+ not_before: notBefore,
89
+ time_until_expiry: timeUntilExpiry,
90
+ warnings,
91
+ };
92
+ }
93
+ function checkJWTExpiry(token) {
94
+ const decoded = decodeJWT(token);
95
+ return {
96
+ is_expired: decoded.is_expired,
97
+ expires_at: decoded.expires_at,
98
+ time_until_expiry: decoded.time_until_expiry,
99
+ issued_at: decoded.issued_at,
100
+ };
101
+ }
102
+ function createUnsignedJWT(payload, expiresInSeconds) {
103
+ const header = { alg: "none", typ: "JWT" };
104
+ const now = Math.floor(Date.now() / 1000);
105
+ const fullPayload = {
106
+ iat: now,
107
+ ...payload,
108
+ };
109
+ if (expiresInSeconds !== undefined && expiresInSeconds > 0) {
110
+ fullPayload.exp = now + expiresInSeconds;
111
+ }
112
+ const headerB64 = base64UrlEncode(JSON.stringify(header));
113
+ const payloadB64 = base64UrlEncode(JSON.stringify(fullPayload));
114
+ const token = `${headerB64}.${payloadB64}.`;
115
+ return {
116
+ token,
117
+ header,
118
+ payload: fullPayload,
119
+ warning: "This is an UNSIGNED token (alg: none). For testing/development only. Never use in production authentication.",
120
+ };
121
+ }
122
+ function formatDuration(ms) {
123
+ const seconds = Math.floor(ms / 1000);
124
+ if (seconds < 60)
125
+ return `${seconds}s`;
126
+ const minutes = Math.floor(seconds / 60);
127
+ if (minutes < 60)
128
+ return `${minutes}m ${seconds % 60}s`;
129
+ const hours = Math.floor(minutes / 60);
130
+ if (hours < 24)
131
+ return `${hours}h ${minutes % 60}m`;
132
+ const days = Math.floor(hours / 24);
133
+ return `${days}d ${hours % 24}h`;
134
+ }
135
+ //# sourceMappingURL=jwt-tools.js.map
@@ -0,0 +1,28 @@
1
+ interface PasswordOptions {
2
+ length?: number;
3
+ uppercase?: boolean;
4
+ lowercase?: boolean;
5
+ digits?: boolean;
6
+ symbols?: boolean;
7
+ exclude_ambiguous?: boolean;
8
+ count?: number;
9
+ }
10
+ interface GeneratedPassword {
11
+ passwords: string[];
12
+ length: number;
13
+ charset_size: number;
14
+ entropy_bits: number;
15
+ }
16
+ export declare function generatePassword(options?: PasswordOptions): GeneratedPassword;
17
+ interface StrengthResult {
18
+ password_length: number;
19
+ entropy_bits: number;
20
+ strength: "very_weak" | "weak" | "fair" | "strong" | "very_strong";
21
+ score: number;
22
+ warnings: string[];
23
+ crack_time_estimate: string;
24
+ charset_size: number;
25
+ }
26
+ export declare function checkPasswordStrength(password: string): StrengthResult;
27
+ export {};
28
+ //# sourceMappingURL=password-tools.d.ts.map
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generatePassword = generatePassword;
7
+ exports.checkPasswordStrength = checkPasswordStrength;
8
+ const node_crypto_1 = __importDefault(require("node:crypto"));
9
+ const COMMON_PASSWORDS = new Set([
10
+ "password", "123456", "12345678", "qwerty", "abc123", "monkey", "1234567",
11
+ "letmein", "trustno1", "dragon", "baseball", "iloveyou", "master", "sunshine",
12
+ "ashley", "bailey", "shadow", "123123", "654321", "superman", "qazwsx",
13
+ "michael", "football", "password1", "password123", "admin", "welcome",
14
+ "hello", "charlie", "donald", "login", "princess", "starwars",
15
+ ]);
16
+ const COMMON_PATTERNS = [
17
+ { name: "all_lowercase", pattern: /^[a-z]+$/ },
18
+ { name: "all_uppercase", pattern: /^[A-Z]+$/ },
19
+ { name: "all_digits", pattern: /^\d+$/ },
20
+ { name: "sequential_digits", pattern: /(?:012|123|234|345|456|567|678|789|890)/ },
21
+ { name: "repeated_chars", pattern: /(.)\1{2,}/ },
22
+ { name: "keyboard_pattern", pattern: /(?:qwert|asdf|zxcv|qazwsx|poiuy)/i },
23
+ { name: "date_pattern", pattern: /(?:19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])/ },
24
+ ];
25
+ function generatePassword(options = {}) {
26
+ const { length = 16, uppercase = true, lowercase = true, digits = true, symbols = true, exclude_ambiguous = false, count = 1, } = options;
27
+ const len = Math.min(Math.max(4, length), 256);
28
+ const n = Math.min(Math.max(1, count), 100);
29
+ let chars = "";
30
+ const required = [];
31
+ const uppercaseChars = exclude_ambiguous ? "ABCDEFGHJKLMNPQRSTUVWXYZ" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
32
+ const lowercaseChars = exclude_ambiguous ? "abcdefghjkmnpqrstuvwxyz" : "abcdefghijklmnopqrstuvwxyz";
33
+ const digitChars = exclude_ambiguous ? "23456789" : "0123456789";
34
+ const symbolChars = "!@#$%^&*()_+-=[]{}|;:,.<>?";
35
+ if (uppercase) {
36
+ chars += uppercaseChars;
37
+ required.push(uppercaseChars);
38
+ }
39
+ if (lowercase) {
40
+ chars += lowercaseChars;
41
+ required.push(lowercaseChars);
42
+ }
43
+ if (digits) {
44
+ chars += digitChars;
45
+ required.push(digitChars);
46
+ }
47
+ if (symbols) {
48
+ chars += symbolChars;
49
+ required.push(symbolChars);
50
+ }
51
+ if (chars.length === 0) {
52
+ chars = lowercaseChars + uppercaseChars + digitChars;
53
+ required.push(lowercaseChars, uppercaseChars, digitChars);
54
+ }
55
+ const passwords = [];
56
+ for (let i = 0; i < n; i++) {
57
+ let password;
58
+ let attempts = 0;
59
+ do {
60
+ const bytes = node_crypto_1.default.randomBytes(len);
61
+ const arr = [];
62
+ for (let j = 0; j < len; j++) {
63
+ arr.push(chars[bytes[j] % chars.length]);
64
+ }
65
+ // Ensure at least one character from each required set
66
+ for (let r = 0; r < required.length && r < len; r++) {
67
+ const reqSet = required[r];
68
+ if (!arr.some((c) => reqSet.includes(c))) {
69
+ const pos = node_crypto_1.default.randomInt(len);
70
+ const randByte = node_crypto_1.default.randomBytes(1)[0];
71
+ arr[pos] = reqSet[randByte % reqSet.length];
72
+ }
73
+ }
74
+ password = arr.join("");
75
+ attempts++;
76
+ } while (attempts < 10 && required.some((req) => !password.split("").some((c) => req.includes(c))));
77
+ passwords.push(password);
78
+ }
79
+ const charsetSize = chars.length;
80
+ const entropyBits = Math.round(len * Math.log2(charsetSize) * 100) / 100;
81
+ return { passwords, length: len, charset_size: charsetSize, entropy_bits: entropyBits };
82
+ }
83
+ function checkPasswordStrength(password) {
84
+ const warnings = [];
85
+ let charsetSize = 0;
86
+ if (/[a-z]/.test(password))
87
+ charsetSize += 26;
88
+ if (/[A-Z]/.test(password))
89
+ charsetSize += 26;
90
+ if (/\d/.test(password))
91
+ charsetSize += 10;
92
+ if (/[^a-zA-Z0-9]/.test(password))
93
+ charsetSize += 32;
94
+ if (charsetSize === 0)
95
+ charsetSize = 1;
96
+ const entropyBits = Math.round(password.length * Math.log2(charsetSize) * 100) / 100;
97
+ // Check common passwords
98
+ if (COMMON_PASSWORDS.has(password.toLowerCase())) {
99
+ warnings.push("This is a commonly used password");
100
+ }
101
+ // Check patterns
102
+ for (const { name, pattern } of COMMON_PATTERNS) {
103
+ if (pattern.test(password)) {
104
+ warnings.push(`Contains ${name.replace(/_/g, " ")} pattern`);
105
+ }
106
+ }
107
+ if (password.length < 8)
108
+ warnings.push("Password is shorter than 8 characters");
109
+ if (password.length < 12)
110
+ warnings.push("Consider using 12+ characters");
111
+ // Unique characters ratio
112
+ const uniqueRatio = new Set(password).size / password.length;
113
+ if (uniqueRatio < 0.5)
114
+ warnings.push("Low character diversity");
115
+ // Score calculation (0-100)
116
+ let score = 0;
117
+ score += Math.min(30, password.length * 2);
118
+ score += Math.min(20, entropyBits / 4);
119
+ if (/[a-z]/.test(password) && /[A-Z]/.test(password))
120
+ score += 10;
121
+ if (/\d/.test(password))
122
+ score += 10;
123
+ if (/[^a-zA-Z0-9]/.test(password))
124
+ score += 15;
125
+ score += Math.min(15, uniqueRatio * 15);
126
+ score -= warnings.length * 5;
127
+ score = Math.max(0, Math.min(100, Math.round(score)));
128
+ let strength;
129
+ if (score < 20)
130
+ strength = "very_weak";
131
+ else if (score < 40)
132
+ strength = "weak";
133
+ else if (score < 60)
134
+ strength = "fair";
135
+ else if (score < 80)
136
+ strength = "strong";
137
+ else
138
+ strength = "very_strong";
139
+ const crackTime = estimateCrackTime(entropyBits);
140
+ return {
141
+ password_length: password.length,
142
+ entropy_bits: entropyBits,
143
+ strength,
144
+ score,
145
+ warnings,
146
+ crack_time_estimate: crackTime,
147
+ charset_size: charsetSize,
148
+ };
149
+ }
150
+ function estimateCrackTime(entropyBits) {
151
+ // Assume 10 billion guesses per second (modern GPU)
152
+ const guessesPerSecond = 1e10;
153
+ const totalGuesses = Math.pow(2, entropyBits);
154
+ const seconds = totalGuesses / guessesPerSecond / 2; // average case
155
+ if (seconds < 0.001)
156
+ return "instant";
157
+ if (seconds < 1)
158
+ return "less than a second";
159
+ if (seconds < 60)
160
+ return `${Math.round(seconds)} seconds`;
161
+ if (seconds < 3600)
162
+ return `${Math.round(seconds / 60)} minutes`;
163
+ if (seconds < 86400)
164
+ return `${Math.round(seconds / 3600)} hours`;
165
+ if (seconds < 31536000)
166
+ return `${Math.round(seconds / 86400)} days`;
167
+ if (seconds < 31536000 * 1000)
168
+ return `${Math.round(seconds / 31536000)} years`;
169
+ if (seconds < 31536000 * 1e6)
170
+ return `${Math.round(seconds / 31536000 / 1000)}k years`;
171
+ if (seconds < 31536000 * 1e9)
172
+ return `${Math.round(seconds / 31536000 / 1e6)}M years`;
173
+ return "billions of years+";
174
+ }
175
+ //# sourceMappingURL=password-tools.js.map
@@ -0,0 +1,20 @@
1
+ export declare function generateUUIDv4(count?: number): {
2
+ uuids: string[];
3
+ };
4
+ export declare function generateNanoid(length?: number, count?: number): {
5
+ ids: string[];
6
+ length: number;
7
+ alphabet: string;
8
+ };
9
+ export declare function generateULID(count?: number): {
10
+ ulids: string[];
11
+ };
12
+ export declare function generateCUID(count?: number): {
13
+ cuids: string[];
14
+ };
15
+ export declare function generateRandomString(length?: number, charset?: string, count?: number): {
16
+ strings: string[];
17
+ length: number;
18
+ charset_used: string;
19
+ };
20
+ //# sourceMappingURL=uuid-generator.d.ts.map
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateUUIDv4 = generateUUIDv4;
7
+ exports.generateNanoid = generateNanoid;
8
+ exports.generateULID = generateULID;
9
+ exports.generateCUID = generateCUID;
10
+ exports.generateRandomString = generateRandomString;
11
+ const node_crypto_1 = __importDefault(require("node:crypto"));
12
+ function generateUUIDv4(count = 1) {
13
+ const n = Math.min(Math.max(1, count), 100);
14
+ const uuids = [];
15
+ for (let i = 0; i < n; i++) {
16
+ uuids.push(node_crypto_1.default.randomUUID());
17
+ }
18
+ return { uuids };
19
+ }
20
+ function generateNanoid(length = 21, count = 1) {
21
+ const alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-";
22
+ const n = Math.min(Math.max(1, count), 100);
23
+ const len = Math.min(Math.max(1, length), 256);
24
+ const ids = [];
25
+ for (let i = 0; i < n; i++) {
26
+ const bytes = node_crypto_1.default.randomBytes(len);
27
+ let id = "";
28
+ for (let j = 0; j < len; j++) {
29
+ id += alphabet[bytes[j] % alphabet.length];
30
+ }
31
+ ids.push(id);
32
+ }
33
+ return { ids, length: len, alphabet };
34
+ }
35
+ function generateULID(count = 1) {
36
+ const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
37
+ const n = Math.min(Math.max(1, count), 100);
38
+ const ulids = [];
39
+ for (let i = 0; i < n; i++) {
40
+ const now = Date.now();
41
+ let timeStr = "";
42
+ let t = now;
43
+ for (let j = 0; j < 10; j++) {
44
+ timeStr = ENCODING[t % 32] + timeStr;
45
+ t = Math.floor(t / 32);
46
+ }
47
+ const randomBytes = node_crypto_1.default.randomBytes(10);
48
+ let randomStr = "";
49
+ for (let j = 0; j < 16; j++) {
50
+ const byteIdx = Math.floor((j * 10) / 16);
51
+ const bitOffset = (j * 5) % 8;
52
+ const val = ((randomBytes[byteIdx] >> bitOffset) |
53
+ ((byteIdx + 1 < 10 ? randomBytes[byteIdx + 1] : 0) << (8 - bitOffset))) &
54
+ 0x1f;
55
+ randomStr += ENCODING[val];
56
+ }
57
+ ulids.push(timeStr + randomStr);
58
+ }
59
+ return { ulids };
60
+ }
61
+ function generateCUID(count = 1) {
62
+ const n = Math.min(Math.max(1, count), 100);
63
+ const cuids = [];
64
+ const BASE36 = "0123456789abcdefghijklmnopqrstuvwxyz";
65
+ function toBase36(num, pad) {
66
+ let result = "";
67
+ let v = Math.abs(Math.floor(num));
68
+ do {
69
+ result = BASE36[v % 36] + result;
70
+ v = Math.floor(v / 36);
71
+ } while (v > 0);
72
+ return result.padStart(pad, "0").slice(-pad);
73
+ }
74
+ for (let i = 0; i < n; i++) {
75
+ const timestamp = toBase36(Date.now(), 8);
76
+ const randomBlock1 = toBase36(parseInt(node_crypto_1.default.randomBytes(4).toString("hex"), 16), 8);
77
+ const randomBlock2 = toBase36(parseInt(node_crypto_1.default.randomBytes(4).toString("hex"), 16), 8);
78
+ cuids.push("c" + timestamp + randomBlock1 + randomBlock2);
79
+ }
80
+ return { cuids };
81
+ }
82
+ function generateRandomString(length = 16, charset = "alphanumeric", count = 1) {
83
+ const charsets = {
84
+ alphanumeric: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
85
+ alpha: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
86
+ numeric: "0123456789",
87
+ hex: "0123456789abcdef",
88
+ lowercase: "abcdefghijklmnopqrstuvwxyz",
89
+ uppercase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
90
+ symbols: "!@#$%^&*()_+-=[]{}|;:,.<>?",
91
+ all: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=[]{}|;:,.<>?",
92
+ };
93
+ const chars = charsets[charset] || charset;
94
+ if (chars.length === 0)
95
+ throw new Error("Charset must not be empty");
96
+ const len = Math.min(Math.max(1, length), 1024);
97
+ const n = Math.min(Math.max(1, count), 100);
98
+ const strings = [];
99
+ for (let i = 0; i < n; i++) {
100
+ const bytes = node_crypto_1.default.randomBytes(len);
101
+ let result = "";
102
+ for (let j = 0; j < len; j++) {
103
+ result += chars[bytes[j] % chars.length];
104
+ }
105
+ strings.push(result);
106
+ }
107
+ return { strings, length: len, charset_used: charset in charsets ? charset : "custom" };
108
+ }
109
+ //# sourceMappingURL=uuid-generator.js.map
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@rog0x/mcp-crypto-tools",
3
+ "version": "1.0.0",
4
+ "description": "Cryptography and encoding tools for AI agents via MCP",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "start": "node dist/index.js"
10
+ },
11
+ "dependencies": {
12
+ "@modelcontextprotocol/sdk": "^1.12.1"
13
+ },
14
+ "devDependencies": {
15
+ "typescript": "^5.7.3",
16
+ "@types/node": "^22.15.3"
17
+ },
18
+ "license": "MIT"
19
+ }