Daily developer enhancement tools - A collection of CLI utilities for common development tasks including ID generation, cryptography, data formatting, QR code generation, time utilities, and SSL certificate management.
npm install -g sarraOr use directly with npx:
npx sarra <command>npm install sarraβ See SDK Documentation below for using Sarra in your Node.js/React applications.
# Generate a UUID
sarra id uuid
# Hash some data
sarra crypto hash sha256 "hello world"
# Format JSON
echo '{"a":1}' | sarra data json format
# Generate a QR code
sarra qr generate "Hello World"
# Get current timestamp
sarra time now
# Generate SSL certificate for local development
sarra ssl generateid- Identifiers, tokens, UUIDs (detailed docs)crypto- Cryptography utilities (detailed docs)data- Data encoding and formatting (detailed docs)qr- QR code generation (detailed docs)time- Date and time utilities (detailed docs)ssl- SSL certificate generation (detailed docs)ssl- Geolocation and IP location utilities (detailed docs)
Use --help on any command for more details:
sarra --help
sarra id --help
sarra crypto --help
sarra qr --help
sarra ssl --helpGenerate and manage identifiers, tokens, and unique values commonly used in databases, APIs, authentication, and distributed systems.
π View detailed documentation
uuid- Generate UUIDs (v4, v7)random- Generate cryptographically secure random tokens
# Generate UUID
sarra id uuid
# Generate UUID v7 (time-ordered, recommended for databases)
sarra id uuid --uuid-version v7 --count 5
# Generate random token
sarra id random --length 32
# Output to file
sarra id uuid --count 10 -o uuids.txt
# JSON format
sarra id --format json uuid --uuid-version v7 -o uuids.jsonCommands will prompt before saving:
π Save Location
Current directory: /home/user/projects
Default file: uuids.txt
Full path: /home/user/projects/uuids.txt
Save to file? (Y/n/path):
- Press Enter or
yβ Save to default location - Type
nβ Output to stdout - Type a path β Save to custom location
- Use
-yflag to skip prompt and output to stdout - Use
-o <file>flag to save directly without prompt
Cryptographic utilities for hashing, encoding, and encryption.
hash- Generate cryptographic hashes (md5, sha1, sha256, sha512)base64- Base64 encode or decode dataaes-encrypt- Encrypt data using AES-256-GCMaes-decrypt- Decrypt AES-256-GCM encrypted datarsa-keygen- Generate RSA key pairrsa-encrypt- Encrypt data using RSA public keyrsa-decrypt- Decrypt data using RSA private key
--format <format> Output format: text | json
# Generate hashes
sarra crypto hash sha256 "hello world"
sarra crypto hash sha512 "data"
echo "hello" | sarra crypto hash sha256
# JSON output
sarra crypto --format json hash sha256 "data"# Encode and decode
sarra crypto base64 "hello world"
sarra crypto base64 --decode SGVsbG8gd29ybGQ=
echo "hello" | sarra crypto base64# Encrypt (auto-generates key)
sarra crypto aes-encrypt "secret message"
# Encrypt with custom key
sarra crypto aes-encrypt "message" -k <64-hex-chars>
# Decrypt (requires key, IV, auth tag)
sarra crypto aes-decrypt <encrypted-hex> -k <key> -i <iv> -t <tag>
# JSON format (saves all parameters)
sarra crypto --format json aes-encrypt "data" -o encrypted.json# Generate key pair
sarra crypto rsa-keygen
sarra crypto rsa-keygen --size 4096 -o ./my-keys
# Encrypt/Decrypt
sarra crypto rsa-encrypt "message" -p public_key.pem
sarra crypto rsa-decrypt <base64-data> -k private_key.pem# Interactive prompt (default)
sarra crypto hash sha256 "data"
# Output to stdout
sarra crypto hash sha256 "data" -y
# Save to file
sarra crypto hash sha256 "data" -o hash.txt
sarra crypto --format json aes-encrypt "data" -o encrypted.jsonHash Algorithms:
md5- 128-bit (not cryptographically secure)sha1- 160-bit (deprecated for security)sha256- 256-bit (recommended)sha512- 512-bit (maximum security)
Encryption:
AES-256-GCM- Authenticated symmetric encryption (256-bit key)RSA-OAEP- Asymmetric encryption (2048/3072/4096-bit keys)
sarra crypto hash <algorithm> [input] [options]
Options:
-o, --out <file> Write output to file
-y, --yes Output to stdoutsarra crypto base64 [input] [options]
Options:
-d, --decode Decode instead of encode
-o, --out <file> Write output to file
-y, --yes Output to stdoutsarra crypto aes-encrypt [input] [options]
Options:
-k, --key <key> Encryption key (hex, 32 bytes)
-o, --out <file> Write output to file
-y, --yes Output to stdoutsarra crypto aes-decrypt [input] [options]
Options:
-k, --key <key> Decryption key (required)
-i, --iv <iv> Initialization vector (required)
-t, --tag <tag> Auth tag (required)
-o, --out <file> Write output to file
-y, --yes Output to stdoutsarra crypto rsa-keygen [options]
Options:
-s, --size <bits> Key size: 2048, 3072, 4096 (default: 2048)
-o, --out <dir> Output directory
-y, --yes Output to stdoutsarra crypto rsa-encrypt [input] [options]
Options:
-p, --public-key <file> Public key file (required)
-o, --out <file> Write output to file
-y, --yes Output to stdoutsarra crypto rsa-decrypt [input] [options]
Options:
-k, --private-key <file> Private key file (required)
-o, --out <file> Write output to file
-y, --yes Output to stdoutβ οΈ AES: Save encryption keys securely - you cannot decrypt without them. Use JSON format to save all decryption parameters together.- π RSA: Keep private keys secure and never share them. Use
chmod 600on private key files. - β Use SHA-256 or SHA-512 for cryptographically secure hashing.
- β For large data, use RSA to encrypt an AES key, then use AES for the data.
JSON utilities for formatting, validating, querying, and transforming JSON data.
π View detailed documentation
format(pretty) - Pretty-print JSON with configurable indentationminify(min) - Minify JSON by removing whitespacevalidate(check) - Validate JSON syntaxquery(get) - Extract values using dot notation pathmerge- Merge multiple JSON files into oneto-csv- Convert JSON array to CSV format
# Format JSON
sarra data json format data.json
# Format with custom indentation
sarra data json format data.json -i 4
# Minify JSON
sarra data json minify large.json -o min.json
# Validate JSON
sarra data json validate config.json
# Query/extract data
sarra data json query "user.name" data.json
sarra data json query "items[0].id" data.json
# Merge JSON files
sarra data json merge config1.json config2.json -o merged.json
# Convert to CSV
sarra data json to-csv users.json -o users.csv
# Pipe workflows
curl https://api.example.com/data | sarra data json formatQR code generation utilities for creating scannable codes from text, URLs, and files.
π View detailed documentation
generate(gen) - Generate QR code from textterminal(term) - Display QR code as ASCII art only (no file)url- Generate QR code from a URLfile- Generate QR code from file content
# Generate QR code
sarra qr generate "Hello World"
# Generate with terminal preview
sarra qr generate "Data" -t
# Quick ASCII preview (no file)
sarra qr terminal "Quick check"
# Generate from URL
sarra qr url https://github.com
# Generate from file
sarra qr file config.json
# Custom size and colors
sarra qr generate "Styled" -s 500 --dark '#FF0000' --light '#FFFF00'
# Save to file
sarra qr generate "Data" -o qrcode.png
# High error correction for damaged codes
sarra qr generate "Important" -e H -o code.png- L - Low (7% recovery)
- M - Medium (15% recovery) [default]
- Q - Quartile (25% recovery)
- H - High (30% recovery)
- 300px - Screen display, mobile sharing
- 400px - General purpose, web embedding
- 500-800px - Printing on paper, posters
- 1000px+ - Large format printing, banners
Date and time utilities for scripting, logging, and debugging.
π View detailed documentation
now- Print the current timestamp
# Current timestamp (ISO 8601)
sarra time now
# Unix timestamp (seconds)
sarra time now --unix
# Unix timestamp (milliseconds)
sarra time now --ms
# Date only
sarra time now --format date
# Time only
sarra time now --format time
# Use in scripts
echo "Started at $(sarra time now)"- Default (ISO 8601):
2026-01-21T13:45:22.123Z --unix:1737468322--ms:1737468322123--format date:2026-01-21--format time:13:45:22.123
SSL/TLS certificate generation for local development and production environments. Generate self-signed certificates instantly or obtain trusted certificates from Let's Encrypt.
π View detailed documentation
generate- Generate self-signed SSL certificates for local developmentletsencrypt- Obtain trusted SSL certificates from Let's Encrypt for production
# Generate self-signed certificate for localhost
sarra ssl generate
# Generate for custom local domain
sarra ssl generate --domain myapp.local
# Generate with custom validity period
sarra ssl generate --domain dev.example.com --validity 90
# Get Let's Encrypt certificate (standalone mode)
sarra ssl letsencrypt -d example.com -e admin@example.com --standalone
# Get Let's Encrypt certificate (with existing web server)
sarra ssl letsencrypt -d example.com -e admin@example.com --webroot /var/www/html
# Test Let's Encrypt setup first
sarra ssl letsencrypt -d example.com -e admin@example.com --standalone --stagingssl generate - Self-Signed Certificates
- β
Local development (
https://localhost) - β Internal testing environments
- β Development teams (share certificate)
- β NOT for production websites
- β NOT for public applications
ssl letsencrypt - Let's Encrypt Certificates
- β Production websites
- β Public-facing applications
- β Any service requiring browser trust
- β NOT for localhost development
- β NOT for offline environments
- Key Algorithm: RSA 2048-bit
- Signature Algorithm: SHA-256
- Validity: Up to 365 days
- Output:
.crtand.keyfiles in PEM format
-
Certbot installed:
- macOS:
brew install certbot - Ubuntu:
sudo apt install certbot - Windows: Download from https://certbot.eff.org
- macOS:
-
Domain ownership:
- Real domain (not
localhostor.local) - DNS points to your server's IP
- Verify:
dig +short example.com
- Real domain (not
-
Network access:
- Port 80 open and accessible
- Firewall allows incoming connections
To eliminate browser warnings during local development:
macOS:
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ./certs/localhost.crtWindows (as Administrator):
certutil -addstore -f "ROOT" ./certs/localhost.crtLinux:
sudo cp ./certs/localhost.crt /usr/local/share/ca-certificates/
sudo update-ca-certificatesNote: This only trusts the certificate on your machine. Other users will still see warnings.
Most commands support an interactive mode that prompts you before saving files:
π Save Location
Current directory: /home/user/projects
Default file: output.txt
Full path: /home/user/projects/output.txt
Save to file? (Y/n/path):
Your options:
- Press Enter or type y β Save to default location
- Type n β Output to stdout (terminal)
- Type a custom path β Save to specified location
Skip the prompt:
- Use
-yflag to output directly to stdout - Use
-o <file>flag to save directly to a file
Examples:
# Interactive (will prompt)
sarra id uuid --count 5
# Skip prompt, output to stdout
sarra id uuid --count 5 -y
# Skip prompt, save to file
sarra id uuid --count 5 -o uuids.txt
# Custom nested path (auto-creates directories)
sarra qr generate "Data" -o ./output/qrcodes/code.png# API response to formatted JSON
curl https://api.example.com/data | sarra data json format
# Hash pipeline
echo "data" | sarra crypto base64 | sarra crypto hash sha256
# Format then minify
sarra data json format ugly.json | sarra data json minify -o min.json
# Validate before processing
sarra data json validate data.json && sarra data json query "users" data.json# Direct file output
sarra id uuid --count 100 -o uuids.txt
sarra crypto hash sha256 "data" -o hash.txt
sarra qr generate "https://example.com" -o qr.png
sarra ssl generate --domain myapp.local
# Nested directories (auto-created)
sarra id random --length 32 -o ./secrets/tokens/api-key.txt
sarra data json format data.json -o ./output/formatted/data.json# Global format flag (before subcommand)
sarra id --format json uuid --count 5
sarra crypto --format json hash sha256 "data"
# Save JSON output
sarra id --format json uuid -o uuids.json
sarra crypto --format json base64 "data" -o encoded.jsonIP address and geolocation utilities for network information. Commands
my-ip - Get your current public IP address
lookup - Get geolocation information for an IP address
validate - Validate an IP address (IPv4 or IPv6)
local - Get local network interface informationsarra geo my-ipsarra geo my-ip --ipv4sarra geo lookup 8.8.8.8sarra geo lookupsarra geo validate 192.168.1.1
sarra geo validate 2001:0db8:85a3:0000:0000:8a2e:0370:7334sarra geo local
sarra geo --format json my-ip
sarra geo --format json lookup 1.1.1.1Options:
-4, --ipv4 Show only IPv4 address
-6, --ipv6 Show only IPv6 addressArguments: ip IP address to validate
my-ip and lookup commands require internet connection
lookup uses ipapi.co free API (rate limited to 1000 requests/day)
validate and local work offline
Local command skips loopback interfaces
All commands support --format json for programmatic usage- Use
--helpon any command for detailed information - Use
--versionto see the current version - Global options like
--formatmust appear before the subcommand - Many commands support reading from stdin for pipeline operations
- Directories are automatically created when using
-o/--out - Use
-yflag to skip interactive prompts and output to stdout - Use
-oflag to save directly to a file without prompts - SSL certificates are zero-dependency - no OpenSSL installation required
Detailed documentation for each command group:
- ID Commands (UUID, Random Tokens)
- Crypto Commands (Hash, Base64)
- Data Commands (JSON utilities)
- QR Code Commands
- Time Commands
- SSL Commands (Certificate Generation)
- Geo and IP Commands
# Generate API key
sarra id random --length 32 -o api-key.txt
# Hash password
echo "mypassword" | sarra crypto hash sha256
# Format API response
curl https://api.example.com/users | sarra data json format
# Setup local HTTPS development
sarra ssl generate --domain localhost# Merge configs
sarra data json merge base.json env.json local.json -o config.json
# Validate config
sarra data json validate config.json
# Extract specific config
sarra data json query "database.host" config.json# WiFi QR code
sarra qr generate "WIFI:T:WPA;S:MyNetwork;P:password;;" -o wifi.png
# URL sharing
sarra qr url https://myapp.com -s 500 -o share.png
# Contact info
sarra qr generate "BEGIN:VCARD..." -e H -o contact.png# Extract users and convert to CSV
sarra data json query "users" data.json | sarra data json to-csv -o users.csv
# Format then validate
sarra data json format raw.json | sarra data json validate# Local development environment
sarra ssl generate --domain localhost
sarra ssl generate --domain myapp.local --validity 180
# Production website deployment
sarra ssl letsencrypt -d example.com -e admin@example.com --standalone
# Multiple environments
sarra ssl generate --domain dev.myapp.local
sarra ssl generate --domain staging.myapp.local
sarra ssl letsencrypt -d myapp.com -e ops@myapp.com --webroot /var/www/html# Generate unique deployment IDs
sarra id uuid --uuid-version v7 -y
# Hash artifact checksums
cat build.zip | sarra crypto hash sha256 -o checksum.txt
# Validate configuration files
sarra data json validate config.json && deploy.sh
# Generate QR codes for mobile app testing
sarra qr url "https://testflight.apple.com/join/abc123" -o testflight.png
# Timestamp build logs
echo "Build started: $(sarra time now)" >> build.logβ οΈ Only for development - browsers will show warningsβ οΈ Not trusted by default - requires manual installationβ οΈ Never use in production - visitors will see security errors
- β Automatically trusted by all browsers and devices
- β Free and automated - renews every 90 days
- β Production-ready - industry-standard security
β οΈ Requires domain ownership - cannot be used for localhostβ οΈ Rate limited - 50 certificates per domain per week
- Use
ssl generatefor local development - Test Let's Encrypt with
--stagingflag first - Never commit
.keyfiles to version control - Rotate certificates regularly
- Keep certbot updated for security patches
"Certbot not found"
- Install certbot:
brew install certbot(macOS) orsudo apt install certbot(Linux)
"Let's Encrypt doesn't work with localhost"
- Use
sarra ssl generatefor local development instead
"Domain must point to this server's IP"
- Verify DNS:
dig +short example.comshould show your server's IP
"Port 80 must be accessible"
- Check firewall rules:
sudo ufw status - Ensure no other service is using port 80
"Command not found"
- Reinstall globally:
npm install -g sarra - Check PATH:
echo $PATH
"Permission denied" when saving files
- Use
sudofor system directories - Save to user-writable locations instead
JSON validation fails
- Check for trailing commas
- Verify quote types (must use double quotes)
- Use
sarra data json formatto auto-fix formatting
Use Sarra's powerful utilities in your Node.js and React applications.
// Import the entire SDK
import { sarra } from "sarra";
// Or import specific modules
import { id, crypto, geo } from "sarra";Generate UUIDs and cryptographically secure random tokens.
Generate UUIDs (v4 or v7).
interface UUIDOptions {
version?: "v4" | "v7"; // Default: 'v4'
count?: number; // Default: 1
}
interface UUIDResult {
version: string;
uuids: string[];
}Examples:
// Generate single UUID v4
const result = sarra.id.uuid();
console.log(result.uuids[0]); // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
// Generate 5 UUID v4s
const result = sarra.id.uuid({ count: 5 });
console.log(result.uuids); // Array of 5 UUIDs
// Generate UUID v7 (time-ordered)
const result = sarra.id.uuid({ version: "v7", count: 3 });
console.log(result.uuids); // Array of 3 time-ordered UUIDsGenerate cryptographically secure random tokens.
interface RandomTokenOptions {
length?: number; // Byte length, default: 16
count?: number; // Default: 1
}
interface RandomTokenResult {
tokens: string[];
count: number;
length: number;
encoding: "hex";
}Examples:
// Generate 16-byte token (32 hex characters)
const result = sarra.id.random();
console.log(result.tokens[0]); // '4f3d2e1c0b9a8f7e6d5c4b3a2f1e0d9c'
// Generate 32-byte token (64 hex characters)
const result = sarra.id.random({ length: 32 });
console.log(result.tokens[0]); // 64-character hex string
// Generate multiple tokens
const result = sarra.id.random({ length: 16, count: 5 });
console.log(result.tokens); // Array of 5 tokensHash, encode, encrypt, and decrypt data.
Generate cryptographic hashes.
interface HashOptions {
algorithm: "md5" | "sha1" | "sha256" | "sha512";
input: string;
}Examples:
// SHA-256 hash
const hash = sarra.crypto.hash({
algorithm: "sha256",
input: "hello world",
});
console.log(hash); // 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9'
// MD5 hash
const md5 = sarra.crypto.hash({
algorithm: "md5",
input: "secret",
});Base64 encode or decode strings.
interface Base64Options {
input: string;
decode?: boolean; // Default: false
}Examples:
// Encode
const encoded = sarra.crypto.base64({ input: "hello world" });
console.log(encoded); // 'aGVsbG8gd29ybGQ='
// Decode
const decoded = sarra.crypto.base64({
input: "aGVsbG8gd29ybGQ=",
decode: true,
});
console.log(decoded); // 'hello world'Encrypt data using AES-256-GCM.
interface AESEncryptOptions {
input: string;
key?: string; // Optional 64-char hex string
}
interface AESEncryptResult {
encrypted: string;
iv: string;
authTag: string;
key: string;
}Examples:
// Encrypt with auto-generated key
const result = sarra.crypto.aesEncrypt({
input: "secret message",
});
console.log(result.encrypted); // Encrypted data (hex)
console.log(result.key); // 64-char hex key
console.log(result.iv); // 32-char hex IV
console.log(result.authTag); // 32-char hex auth tag
// Encrypt with custom key
const result = sarra.crypto.aesEncrypt({
input: "secret message",
key: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
});Decrypt AES-256-GCM encrypted data.
interface AESDecryptOptions {
encrypted: string;
key: string;
iv: string;
authTag: string;
}Examples:
// Decrypt data
const decrypted = sarra.crypto.aesDecrypt({
encrypted: result.encrypted,
key: result.key,
iv: result.iv,
authTag: result.authTag,
});
console.log(decrypted); // 'secret message'Generate RSA key pair.
interface RSAKeygenOptions {
size?: 2048 | 3072 | 4096; // Default: 2048
}
interface RSAKeygenResult {
publicKey: string; // PEM format
privateKey: string; // PEM format
}Examples:
// Generate 2048-bit key pair
const keys = sarra.crypto.rsaKeygen();
console.log(keys.publicKey); // '-----BEGIN PUBLIC KEY-----...'
console.log(keys.privateKey); // '-----BEGIN PRIVATE KEY-----...'
// Generate 4096-bit key pair
const keys = sarra.crypto.rsaKeygen({ size: 4096 });Encrypt data using RSA public key.
interface RSAEncryptOptions {
input: string;
publicKey: string; // PEM format
}Examples:
const keys = sarra.crypto.rsaKeygen();
const encrypted = sarra.crypto.rsaEncrypt({
input: "secret message",
publicKey: keys.publicKey,
});
console.log(encrypted); // Base64-encoded encrypted dataDecrypt data using RSA private key.
interface RSADecryptOptions {
encrypted: string; // Base64 format
privateKey: string; // PEM format
}Examples:
const decrypted = sarra.crypto.rsaDecrypt({
encrypted: encrypted,
privateKey: keys.privateKey,
});
console.log(decrypted); // 'secret message'Get IP addresses, validate IPs, and lookup geolocation data.
Get your public IP address.
interface IpInfo {
ip: string;
}Examples:
// Get IPv4 address
const result = await sarra.geo.myIp();
console.log(result.ip); // '203.0.113.42'
// Get IPv6 address
const result = await sarra.geo.myIp(true);
console.log(result.ip); // '2001:0db8:85a3::8a2e:0370:7334'Get geolocation information for an IP address.
interface GeolocationData {
ip: string;
city?: string;
region?: string;
country_name?: string;
country_code?: string;
timezone?: string;
org?: string;
postal?: string;
latitude?: number;
longitude?: number;
}Examples:
// Lookup specific IP
const data = await sarra.geo.lookup("8.8.8.8");
console.log(data.city); // 'Mountain View'
console.log(data.country_name); // 'United States'
console.log(data.org); // 'Google LLC'
// Lookup your own IP
const data = await sarra.geo.lookup();
console.log(data.city, data.country_name);Validate an IP address (IPv4 or IPv6).
interface IpValidation {
ip: string;
valid: boolean;
type: "IPv4" | "IPv6" | null;
}Examples:
// Validate IPv4
const result = sarra.geo.validate("192.168.1.1");
console.log(result.valid); // true
console.log(result.type); // 'IPv4'
// Validate IPv6
const result = sarra.geo.validate("2001:0db8:85a3::8a2e:0370:7334");
console.log(result.valid); // true
console.log(result.type); // 'IPv6'
// Invalid IP
const result = sarra.geo.validate("999.999.999.999");
console.log(result.valid); // false
console.log(result.type); // nullimport { useState } from "react";
import { sarra } from "sarra";
function UUIDGenerator() {
const [uuids, setUuids] = useState<string[]>([]);
const generateUUIDs = () => {
const result = sarra.id.uuid({ version: "v4", count: 5 });
setUuids(result.uuids);
};
return (
<div>
<button onClick={generateUUIDs}>Generate UUIDs</button>
<ul>
{uuids.map((uuid) => (
<li key={uuid}>{uuid}</li>
))}
</ul>
</div>
);
}import { useState } from "react";
import { sarra } from "sarra";
function HashGenerator() {
const [input, setInput] = useState("");
const [hash, setHash] = useState("");
const generateHash = () => {
const result = sarra.crypto.hash({
algorithm: "sha256",
input,
});
setHash(result);
};
return (
<div>
<input
value={input}
onChange={(e) => setInput(e.target.value)}
placeholder="Enter text to hash"
/>
<button onClick={generateHash}>Generate SHA-256</button>
{hash && <code>{hash}</code>}
</div>
);
}import { useState } from "react";
import { sarra } from "sarra";
function IPLookup() {
const [ip, setIp] = useState("");
const [data, setData] = useState(null);
const [loading, setLoading] = useState(false);
const lookup = async () => {
setLoading(true);
try {
const result = await sarra.geo.lookup(ip || undefined);
setData(result);
} catch (error) {
console.error("Lookup failed:", error);
} finally {
setLoading(false);
}
};
return (
<div>
<input
value={ip}
onChange={(e) => setIp(e.target.value)}
placeholder="Enter IP (or leave empty for your IP)"
/>
<button onClick={lookup} disabled={loading}>
{loading ? "Looking up..." : "Lookup"}
</button>
{data && (
<div>
<p>IP: {data.ip}</p>
<p>City: {data.city}</p>
<p>Country: {data.country_name}</p>
<p>ISP: {data.org}</p>
</div>
)}
</div>
);
}import { useState } from "react";
import { sarra } from "sarra";
function Encryptor() {
const [message, setMessage] = useState("");
const [encrypted, setEncrypted] = useState(null);
const [decrypted, setDecrypted] = useState("");
const encrypt = () => {
const result = sarra.crypto.aesEncrypt({ input: message });
setEncrypted(result);
};
const decrypt = () => {
if (!encrypted) return;
const result = sarra.crypto.aesDecrypt({
encrypted: encrypted.encrypted,
key: encrypted.key,
iv: encrypted.iv,
authTag: encrypted.authTag,
});
setDecrypted(result);
};
return (
<div>
<input
value={message}
onChange={(e) => setMessage(e.target.value)}
placeholder="Enter message"
/>
<button onClick={encrypt}>Encrypt</button>
{encrypted && (
<>
<div>
<p>Encrypted: {encrypted.encrypted.slice(0, 50)}...</p>
<p>Key: {encrypted.key.slice(0, 20)}...</p>
</div>
<button onClick={decrypt}>Decrypt</button>
{decrypted && <p>Decrypted: {decrypted}</p>}
</>
)}
</div>
);
}Sarra is written in TypeScript and includes full type definitions.
import { sarra, UUIDOptions, GeolocationData } from "sarra";
const options: UUIDOptions = {
version: "v4",
count: 5,
};
const result = sarra.id.uuid(options);
const data: GeolocationData = await sarra.geo.lookup("8.8.8.8");- All cryptographic operations use Node.js built-in
cryptomodule - AES keys must be exactly 32 bytes (64 hexadecimal characters)
- RSA is suitable for encrypting small amounts of data
- For large files, use RSA to encrypt an AES key, then use AES for the data
myIp()andlookup()require internet connectionlookup()uses ipapi.co free tier (rate limited to 1000 requests/day)validate()works offline (no API calls)- All API calls use HTTPS for secure communication
See the LICENSE file for details.
See CHANGELOG for version history and updates.
Contributions are welcome! Please open an issue or submit a pull request.
![]() Simeon Jordanov |
Planned features for future releases:
- π More data format conversions (YAML, TOML, XML)
- π DNS utilities and domain validation
- π SSH key generation and management
- π¦ Archive utilities (zip, tar)
- π¨ Image processing and optimization
- π File search and text processing

