local path_src = File.GetAbsolute("./src/") local path_out = File.GetAbsolute("./out/") -- 创建输出目录 File.CreateFolder(path_out) local path_key = path_src .. "key.json" if File.IsExist(path_key) then local key = Crypto.GenerateKeyAes256() local j = {} j["key"] = to_string_hex(key._key) j["iv"] = to_string_hex(key._iv, true) j["tag"] = to_string(key._tag) -- test json local j1= {} j1["a"] = "xxx" j1["arr"] = {1, 2, 3} j["test"] = j1 if File.SaveString(json.encode(j), path_key) then print(path_key .. "已保存") else print(path_key .. "保存失败") end end local str = File.GetString(path_src .. "key.json") local j = json.decode(str) print(j.key) print(j.test.arr) print(j.test.arr[1]) local key = Crypto.Aes256Key() key._key = CreateBufferHex(j.key) key._iv = CreateBufferHex(j.iv) key._tag = CreateBufferHex(j.tag) local out = Crypto.EncryptAes256(File.GetBuffer(path_src .. "apple.png"), key) File.SaveBuffer(out, path_out .. "apple.aes256") -- print(param._src.."->"..param._out) print "此工具会将src文件夹的apple.png加密为 apple.aes256" pause()