랭킹으로 돌아가기

jenssegers/optimus

PHPjenssegers.com

🤖 Id obfuscation based on Knuth's multiplicative hashing method for PHP.

obfuscationidsoptimushashidstransformationslaravel
스타 성장
스타
1.3k
포크
75
주간 성장
이슈
10
5001k
2023년 1월2024년 3월2025년 5월2026년 7월
아티팩트Packagistcomposer require jenssegers/optimus
README

Optimus id transformation

Packagist Downloads Build Coverage

With this library, you can transform your internal id's to obfuscated integers based on Knuth's integer hash. It is similar to Hashids, but will generate integers instead of random strings. It is also super fast.

Installation

Install using composer:

composer require jenssegers/optimus

If you will be running your code on a 32 bit system or will be working with large prime numbers it is suggested that you install the GMP extension. For debian/ubuntu you can install the extension with one of these commands:

apt-get install php7.4-gmp
apt-get install php8.0-gmp
apt-get install php8.1-gmp

Usage

To get started you will need 3 things;

  • Large prime number lower than 2147483647
  • The inverse prime so that (PRIME * INVERSE) & MAXID == 1
  • A large random integer lower than 2147483647

Luckily for you, I have included a console command that can do all of this for you. To get started, just run the following command:

> php vendor/bin/optimus spark

Prime: 2123809381
Inverse: 1885413229
Random: 146808189

If you prefer to choose your own prime number (from this list for example), you can pass it to the command to calculate the remaining numbers:

> php vendor/bin/optimus spark 1580030173

Prime: 1580030173
Inverse: 59260789
Random: 1163945558

Using those numbers, you can start creating instances of Optimus($prime, $inverted, $random):

use Jenssegers\Optimus\Optimus;

new Optimus(1580030173, 59260789, 1163945558);

NOTE: Make sure that you are using the same constructor values throughout your entire application!

Encoding and decoding

To encode id's, use the encode method:

$encoded = $optimus->encode(20); // 1535832388

To decode the resulting 1535832388 back to its original value, use the decode method:

$original = $optimus->decode(1535832388); // 20

Framework Integrations

Laravel

This is an example service provider which registers a shared Optimus instance for your entire application:

<?php

namespace App\Providers;

use Jenssegers\Optimus\Optimus;
use Illuminate\Support\ServiceProvider;

class OptimusServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton(Optimus::class, function ($app) {
            return new Optimus(1580030173, 59260789, 1163945558);
        });
    }
}

Once you have created the service provider, add it to the providers array in your config/app.php configuration file:

App\Providers\OptimusServiceProvider::class,

Laravel's automatic injection will pass this instance where needed. Example controller:

<?php

namespace App\Http\Controllers;

use Jenssegers\Optimus\Optimus;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    public function show($id, Optimus $optimus)
    {
        $id = $optimus->decode($id);
    }
}

More information: https://laravel.com/docs/5.3/container#resolving

Third-party integrations

Security contact information

To report a security vulnerability, follow these steps.

License

The MIT License.

관련 저장소
javascript-obfuscator/javascript-obfuscator

A powerful obfuscator for JavaScript and Node.js

TypeScriptnpmBSD 2-Clause "Simplified" Licensejavascript-obfuscatorobfuscation
obfuscator.io
16.2k1.7k
burrowers/garble

Obfuscate Go builds

GoGo ModulesBSD 3-Clause "New" or "Revised" Licensegolangobfuscation
5.6k363
telemt/telemt

MTProxy for Telegram on Rust + Tokio

Rustcrates.ioOtheraes-ctrasync
5.5k251
dashingsoft/pyarmor

A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.

PythonPyPIOtherpythonobfuscation
pyarmor.dashingsoft.com
5.1k358
obfuscar/obfuscar

Open source obfuscation tool for .NET assemblies

C#MIT Licensec-sharpobfuscation
obfuscar.com
3.1k463
rockbruno/swiftshield

🔒 Swift Obfuscator that protects iOS apps against reverse engineering attacks.

SwiftGNU General Public License v3.0swiftobfuscation
swiftrocks.com
2.5k284
rednaga/APKiD

Android Application Identifier for Packers, Protectors, Obfuscators and Oddities - PEiD for Android

YARAOtherandroidantivirus
2.5k342
refraction-networking/utls

Fork of the Go standard TLS library, providing low-level access to the ClientHello for mimicry purposes.

GoGo ModulesBSD 3-Clause "New" or "Revised" Licensetlsclienthello
2.5k354
sevagas/macro_pack

macro_pack is a tool by @EmericNasi used to automatize obfuscation and generation of Office documents, VB scripts, shortcuts, and other formats for pentest, demo, and social engineering assessments. The goal of macro_pack is to simplify exploitation, antimalware bypass, and automatize the process from malicious macro and script generation to final document generation. It also provides a lot of helpful features useful for redteam or security research.

PythonPyPIApache License 2.0pentestsocial-engineering
blog.sevagas.com
2.3k414
520coding/confuse

iOS混淆加固差异化翻新加密工具,模拟人工手动混淆,识别上下文 ,支持继承链、类型识别、方法多参等复杂高级混淆。source-to-source obfuscation of iOS projects,Xcode's refactor->rename. 告别插入毫无关联的垃圾代码、弃用无脑单词随机拼接替换,模拟正常开发,一款最好的混淆最彻底的Mac App Tools。支持OC(Objc、Objective-C)、C、C++(Cocos2d-x、Cocos2dx和Lua游戏开发)、Swift、C#(Unity)混淆,可用于ios马甲包游戏SDK混淆,减少账号调查过机审上架过包过审4.3、2.3.1、2.1

Objective-Cconfuseconfusion
2.1k268
Bashfuscator/Bashfuscator

A fully configurable and extendable Bash obfuscation framework. This tool is intended to help both red team and blue team.

PythonPyPIMIT Licensebashlinux
bashfuscator.readthedocs.io/en/latest/index.html
2k200
JustasMasiulis/lazy_importer

library for importing functions from dlls in a hidden, reverse engineer unfriendly way

C++Apache License 2.0anti-reversingimport
1.9k229