@nixat/cipher
v0.1.0
Published
String manipulation and encryption utilities
Readme
@nixat/cipher
A lightweight utility library for string manipulation and encryption in JavaScript and TypeScript.
Installation
npm install @nixat/cipher
# or
yarn add @nixat/cipher
# or
pnpm add @nixat/cipherUsage
import { cipher } from '@nixat/cipher';
// Capitalize a string
const capitalized = cipher.capitalize('hello world'); // "Hello world"
// Convert to camelCase
const camelCased = cipher.camelCase('hello world'); // "helloWorld"
// Encrypt using Caesar cipher
const encrypted = cipher.caesarEncrypt('Hello', 3); // "Khoor"
const decrypted = cipher.caesarDecrypt('Khoor', 3); // "Hello"API
String Validation
isString(value: unknown): boolean- Checks if the provided value is a string
String Manipulation
reverse(str: string): string- Reverses a stringcapitalize(str: string): string- Capitalizes the first letter of a stringcamelCase(str: string): string- Converts a string to camelCasesnakeCase(str: string): string- Converts a string to snake_casetruncate(str: string, length: number, ellipsis?: string): string- Truncates a string to a specified lengthpad(str: string, length: number, char?: string, padEnd?: boolean): string- Pads a string to a specified lengthcountOccurrences(str: string, substring: string): number- Counts the occurrences of a substring in a string
Encryption
caesarEncrypt(str: string, shift: number): string- Encrypts a string using a Caesar ciphercaesarDecrypt(str: string, shift: number): string- Decrypts a string encrypted with a Caesar ciphervigenereEncrypt(str: string, key: string): string- Encrypts a string using a Vigenère ciphervigenereDecrypt(str: string, key: string): string- Decrypts a string encrypted with a Vigenère cipherhashCode(str: string): number- Generates a hash code for a string
HTML Utilities
escapeHtml(str: string): string- Escapes HTML special characters in a stringunescapeHtml(str: string): string- Unescapes HTML special characters in a string
License
MIT
