Tài liệu
/

Tham khảo API

Tham khảo API

Lấy API key của bạn

  1. Đăng nhập vào Bảng điều khiển của bạn
  2. Nhấn "Create Key" và sao chép API key của bạn
  3. Lưu trữ khóa an toàn (khuyến nghị dùng biến môi trường)

Cách dùng REST API được khuyến nghị

Khuyến nghị: Dùng gói NPM

Với hầu hết các trường hợp, chúng tôi khuyến nghị dùng trực tiếp gói npm javascript-obfuscator (v5.3.0+) qua CLI hoặc Node.js API. Đây cũng là cách duy nhất được hỗ trợ chính thức để làm rối các tệp lớn hơn 4.4MB.

Cài đặt

npm install -g javascript-obfuscator

Ví dụ

# Basic usage (standard obfuscation)
javascript-obfuscator input.js --output output.js

# VM obfuscation (requires Pro API token)
javascript-obfuscator input.js --output output.js \
  --pro-api-token=<YOUR_PRO_API_TOKEN> \
  --vm-obfuscation=true \
  --options-preset=vm-medium-obfuscation  

# VM obfuscation with a specific version (requires Pro API token)
javascript-obfuscator input.js --output output.js \
  --pro-api-token=<YOUR_PRO_API_TOKEN> \
  --pro-api-version=5.0.3 \
  --vm-obfuscation=true \
  --vm-bytecode-format=binary
  
# Obfuscation with Parse HTML option (requires Pro API token)
javascript-obfuscator input.js --output output.js \
  --pro-api-token=<YOUR_PRO_API_TOKEN> \
  --parse-html=true \
  --compact=true \
  --control-flow-flattening=true \
  --dead-code-injection=true \
  --string-array=true

# Standard obfuscation (no token needed)
javascript-obfuscator input.js --output output.js \
  --compact=true \
  --control-flow-flattening=true \
  --dead-code-injection=true \
  --string-array=true

Xem tài liệu CLI để biết tất cả các tùy chọn khả dụng.

Cách dùng REST API thủ công

Endpoint

https://obfuscator.io/api/v1/obfuscate

Phương thức

POST

Headers

Content-Type: application/json

Authorization: Bearer YOUR_API_TOKEN

Tham số truy vấn

version không bắt buộc - Phiên bản trình làm rối cần dùng

Mặc định là bản mới nhất (7.8.0).

Định dạng phản hồi

API dùng luồng NDJSON (application/x-ndjson). Các kết quả lớn được tự động chia thành các mảnh 1MB để truyền tải đáng tin cậy.

code bắt buộc - Mã JavaScript cần làm rối

options - Đối tượng các tùy chọn làm rối

Cần ít nhất một tính năng Pro: vmObfuscation: true hoặc parseHtml: true

Các tùy chọn khả dụng: compact, controlFlowFlattening, deadCodeInjection, stringArray, sourceMap, và nhiều tùy chọn khác.

Xem phần Tham khảo tùy chọn để có danh sách đầy đủ các tùy chọn khả dụng.