-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
53 lines (41 loc) · 1.35 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from flask import Flask, request, jsonify
import subprocess
app = Flask(__name__)
def encrypt_blob(version, blob_array):
blob_array = str(blob_array)
command = ['node', 'deobfuscator.js', version, blob_array]
process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
stdout, stderr = process.communicate()
if stderr:
return {"error": stderr}
return stdout.strip()
@app.route('/encrypt', methods=['POST'])
def encrypt():
try:
data = request.get_json()
if not data or 'version' not in data or 'array' not in data:
return jsonify({
'error': 'Missing required fields. Please provide version and array'
}), 400
version = data['version']
array = data['array']
if not isinstance(array, list):
return jsonify({
'error': 'Array must be a list of numbers'
}), 400
result = encrypt_blob(version, array)
return jsonify({
'success': True,
'result': result
})
except Exception as e:
return jsonify({
'error': str(e)
}), 500
if __name__ == '__main__':
app.run(host='0.0.0.0', port=1337)