{"id":31040005,"url":"https://github.com/jedisct1/ipcrypt-lua","last_synced_at":"2025-09-14T08:03:24.144Z","repository":{"id":312201686,"uuid":"1046660428","full_name":"jedisct1/ipcrypt-lua","owner":"jedisct1","description":"IP obfuscation and encryption using IPCrypt, implemented in Lua.","archived":false,"fork":false,"pushed_at":"2025-08-29T04:05:15.000Z","size":32,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-08T03:56:24.366Z","etag":null,"topics":["encryption","ip","ip-obfuscator","ipcipher","ipcrypt","lua","obfuscation"],"latest_commit_sha":null,"homepage":"https://luarocks.org/modules/jedisct1/ipcrypt","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jedisct1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-29T03:01:48.000Z","updated_at":"2025-09-01T09:17:34.000Z","dependencies_parsed_at":"2025-08-29T07:50:04.736Z","dependency_job_id":null,"html_url":"https://github.com/jedisct1/ipcrypt-lua","commit_stats":null,"previous_names":["jedisct1/ipcrypt-lua"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jedisct1/ipcrypt-lua","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fipcrypt-lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fipcrypt-lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fipcrypt-lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fipcrypt-lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jedisct1","download_url":"https://codeload.github.com/jedisct1/ipcrypt-lua/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fipcrypt-lua/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275076599,"owners_count":25401319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["encryption","ip","ip-obfuscator","ipcipher","ipcrypt","lua","obfuscation"],"created_at":"2025-09-14T08:03:23.013Z","updated_at":"2025-09-14T08:03:24.130Z","avatar_url":"https://github.com/jedisct1.png","language":"Lua","readme":"# IPCrypt - Pure Lua Implementation\n\nA pure Lua implementation of the IPCrypt specification for IP address encryption and obfuscation.\n\n## Features\n\n- **Deterministic encryption** - AES-128 based, always produces same output for same input\n- **Non-deterministic (ND)** - KIASU-BC with 8-byte random tweaks  \n- **Non-deterministic extended (NDX)** - AES-XTS with 16-byte random tweaks\n- **Prefix-preserving (PFX)** - Format-preserving encryption that maintains IPv4/IPv6 type\n- **IPv4 and IPv6 support** - Full support for both address families\n- **Zero dependencies** - Pure Lua implementation\n\n## Requirements\n\n- **Lua 5.3++** - Native bitwise operators required\n- **Unix-like OS** - /dev/urandom or /dev/random required for secure random\n\n## Installation\n\n### Quick Start\n\n```bash\n# Run tests\nmake test\n\n# Generate a secure key\n\nmake keygen\n\n# Run examples\n\nmake example\n```\n\n### System Installation\n\n```bash\n# Install to system (default: /usr/local)\nsudo make install\n\n# Custom prefix\nsudo make install PREFIX=/opt/local\n\n# Uninstall\nsudo make uninstall\n```\n\n### LuaRocks Installation\n\n```bash\nluarocks install ipcrypt-1.0.1-1.rockspec\n```\n\n## Usage\n\n### Basic Usage\n\n```lua\nlocal ipcrypt = require(\"ipcrypt\")\n\n-- Generate secure keys\nlocal key16 = ipcrypt.utils.generate_key(16)  -- For deterministic/ND\nlocal key32 = ipcrypt.utils.generate_key(32)  -- For NDX/PFX\n\n-- Deterministic encryption (same input = same output)\nlocal encrypted = ipcrypt.deterministic.encrypt(\"192.0.2.1\", key16)\nprint(encrypted)  -- IPv6 format: \"fa71:fba4:8e6c:205e:3805:2dae:3fba:39f1\"\n\nlocal decrypted = ipcrypt.deterministic.decrypt(encrypted, key16)\nprint(decrypted)  -- \"192.0.2.1\"\n```\n\n### Non-Deterministic Modes\n\n```lua\n-- ND mode with KIASU-BC (8-byte tweak)\nlocal encrypted_nd = ipcrypt.nd.encrypt(\"10.0.0.1\", key16)\n-- Returns 24 bytes: 8-byte tweak + 16-byte ciphertext\n\nlocal decrypted_nd = ipcrypt.nd.decrypt(encrypted_nd, key16)\nprint(decrypted_nd)  -- \"10.0.0.1\"\n\n-- NDX mode with AES-XTS (16-byte tweak)\nlocal encrypted_ndx = ipcrypt.ndx.encrypt(\"2001:db8::1\", key32)\n-- Returns 32 bytes: 16-byte tweak + 16-byte ciphertext\n\nlocal decrypted_ndx = ipcrypt.ndx.decrypt(encrypted_ndx, key32)\nprint(decrypted_ndx)  -- \"2001:db8::1\"\n```\n\n### Prefix-Preserving Mode (PFX)\n\n```lua\n-- PFX mode maintains IP address type (IPv4 stays IPv4, IPv6 stays IPv6)\nlocal key32 = ipcrypt.utils.generate_key(32)  -- PFX requires 32-byte key\n\n-- IPv4 addresses remain IPv4\nlocal encrypted_v4 = ipcrypt.pfx.encrypt(\"192.168.1.1\", key32)\nprint(encrypted_v4)  -- e.g., \"172.31.45.67\" (still IPv4)\n\nlocal decrypted_v4 = ipcrypt.pfx.decrypt(encrypted_v4, key32)\nprint(decrypted_v4)  -- \"192.168.1.1\"\n\n-- IPv6 addresses remain IPv6\nlocal encrypted_v6 = ipcrypt.pfx.encrypt(\"2001:db8::1\", key32)\nprint(encrypted_v6)  -- e.g., \"c180:5dd4:2587:3524:30ab:fa65:6ab6:f88\" (still IPv6)\n\nlocal decrypted_v6 = ipcrypt.pfx.decrypt(encrypted_v6, key32)\nprint(decrypted_v6)  -- \"2001:db8::1\"\n```\n\n### Key Generation\n\n```bash\n# Command-line tool\n./bin/ipcrypt-keygen              # Generate 16-byte key\n./bin/ipcrypt-keygen -l 32        # Generate 32-byte key\n./bin/ipcrypt-keygen -n 5         # Generate 5 keys\n./bin/ipcrypt-keygen --check      # Check random source\n```\n\n```lua\n-- Programmatic key generation\nlocal utils = require(\"ipcrypt.utils\")\n\n-- Generate keys (fails if no secure random available)\nlocal key16 = utils.generate_key(16)\nlocal key32 = utils.generate_key(32)\n\n-- Get hex representation\nlocal hex_key = utils.generate_key_hex(16)\nprint(hex_key)  -- \"a1b2c3d4...\"\n\n-- Check security\nif utils.has_secure_random() then\n    print(\"Secure random available: \" .. utils.get_random_source())\nend\n```\n\n## API Reference\n\n### Main Module (`ipcrypt`)\n\n- `ipcrypt.VERSION` - Library version string\n- `ipcrypt.deterministic` - Deterministic mode module\n- `ipcrypt.nd` - Non-deterministic mode (KIASU-BC)\n- `ipcrypt.ndx` - Non-deterministic extended mode (AES-XTS)\n- `ipcrypt.pfx` - Prefix-preserving mode\n- `ipcrypt.utils` - Utility functions\n\n### Deterministic Mode (`ipcrypt.deterministic`)\n\n- `encrypt(ip_string, key16)` - Encrypt IP address deterministically\n- `decrypt(encrypted_ip, key16)` - Decrypt to original IP\n\n### ND Mode (`ipcrypt.nd`)\n\n- `encrypt(ip_string, key16, [tweak8])` - Encrypt with optional tweak\n- `decrypt(encrypted_bytes, key16)` - Decrypt (tweak included in data)\n\n### NDX Mode (`ipcrypt.ndx`)\n\n- `encrypt(ip_string, key32, [tweak16])` - Encrypt with optional tweak\n- `decrypt(encrypted_bytes, key32)` - Decrypt (tweak included in data)\n\n### PFX Mode (`ipcrypt.pfx`)\n\n- `encrypt(ip_string, key32)` - Encrypt preserving IP type (IPv4/IPv6)\n- `decrypt(encrypted_ip, key32)` - Decrypt to original IP\n\n### Utils (`ipcrypt.utils`)\n\n- `generate_key(length)` - Generate secure key (16 or 32 bytes)\n- `generate_key_hex(length)` - Generate key as hex string\n- `has_secure_random()` - Check if secure random available\n- `get_random_source()` - Get random source name\n- `random_bytes(n)` - Generate n random bytes\n- `hex_to_bytes(hex)` - Convert hex string to bytes\n- `bytes_to_hex(bytes)` - Convert bytes to hex string\n- `ip_to_bytes(ip_string)` - Convert IP to 16-byte format\n- `bytes_to_ip(bytes16)` - Convert 16 bytes to IP string\n\n## Testing\n\n```bash\n# Run all tests\nmake test\n\n# Run specific tests\ncd tests\nlua test_vectors.lua\nlua test_random.lua\n\n# Run test suite with colored output\n./run-tests.sh\n```\n\n## Troubleshooting\n\n### No secure random source\n\n- Ensure /dev/urandom exists (standard on Linux/macOS/BSD)\n- Check file permissions\n- For Windows, use WSL or consider alternative implementations\n\n### Module not found errors\n\n- Check Lua version: `lua -v` (must be 5.3+)\n- Verify installation paths\n- Use proper require paths or package.path configuration\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjedisct1%2Fipcrypt-lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjedisct1%2Fipcrypt-lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjedisct1%2Fipcrypt-lua/lists"}