// D:\work\TopDFM_JNS\qt5.6.3-win32-msvc2015\topcam\topjs\3.4.0\bin\topjs3.exe
// 从tl解密脚本
var fs = require('fs');
var crypto = require('topsin.crypto');

var files = fs.listDir("./tl")

files.forEach(function (file) {
    var baseName = file.baseName; // 
    var suffix = file.suffix; // 
    var path = file.path; // 
    if(/^tl\d?$/i.test(suffix)) {
        var content = fs.readFile(path)
        var encrypt = 1;
        if(/2/.test(suffix)){encrypt = 2}
        else if (/3/.test(suffix)) {encrypt = 3}
        if(content && content != "") {
            var retC = ""
            if (encrypt == 1) {
                retC = crypto.d(content);
            }
            else if (encrypt == 2) {
                retC = crypto.d2(content);
            }
            else if (encrypt == 3) {
                retC = crypto.d3(content);
            }

            if(!fs.exists("./src")){
                fs.mkdir("./src")
            }

            fs.writeFile("./src/" + baseName, retC)
        }
    }
})








