API Document
This document will introduce how to use jsObf API to encrypt JS code. This API provides two JS code input methods.
General API
POST https://www.jsobf.com/v1/obf
Request parameters
Parameter name |
Required |
Type |
Description |
code |
Y |
String |
JS Code |
level |
N |
Int |
Complexity |
format |
N |
String |
The format of response data supports 'json' and 'xml', default is 'json' |
key |
No |
String |
Key |
Response data parameters
Parameter name |
Type |
Description |
code |
String |
JS Code |
level |
int |
Complexity |
Code example
<?php
$data['content'] = file_get_contents('https://www.jsobf.com/examples/purejs.txt');
$data['format'] = "json";
$data['key'] = "your key";
$opts = array(
'http' =>
array(
'method' => 'POST',
'content' => http_build_query($data)
)
);
$ctx = stream_context_create($opts);
$ret = file_get_contents('https://www.jsobf.com/v1/obf', false, $ctx);
var_dump($ret);
?>
Upload File API
POST https://www.jsobf.com/v1/obffile
Request parameters
Parameter name |
Required |
Type |
Description |
file |
Y |
Binary |
JS File |
level |
N |
Int |
Complexity |
format |
N |
String |
The format of response data supports 'json' and 'xml', default is 'json' |
key |
No |
String |
Key |
Response data parameters
Parameter name |
Type |
Description |
code |
String |
JS Code |
level |
int |
Complexity |
Code Example
<?php
$url = 'https://www.jsobf.com/v1/obffile';
$cfile = curl_file_create(realpath('filename.js'), 'plain/javascript','html');
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt(
$curl,
CURLOPT_POSTFIELDS,
array(
'file' => $cfile,
'xssfilter' => true,
'format' => 'json',
'key' => 'your key'
)
);
$ret = curl_exec($curl);
curl_close($curl);
var_dump($ret);
?>