Esempio n. 1
0
        protected byte[] DoStuffDataOnline(byte[] data, string mode)
        {
            using (UnpackMeClient unpackMeClient = new UnpackMeClient(m_unpackMeUrl))
            {
                unpackMeClient.Authenticate(m_unpackMeClientLogin, m_unpackMeClientPassword);
                var commands = unpackMeClient.GetAvailableCommands();

                var commandName = mode == "decrypt" ? "DJMax *.pt decrypt" : "DJMax *.pt encrypt";

                var decryptCommand = commands.SingleOrDefault(x => x.CommandTitle == commandName);

                using (var stream = new MemoryStream(data))
                {
                    var taskId = unpackMeClient.CreateTaskFromCommandId(decryptCommand.CommandId, stream);

                    TaskModel task;
                    string    taskStatus;
                    do
                    {
                        task       = unpackMeClient.GetTaskById(taskId);
                        taskStatus = task.TaskStatus;

                        System.Threading.Thread.Sleep(500);
                    } while (taskStatus != "completed");

                    return(unpackMeClient.DownloadToByteArray(taskId));
                }
            }
        }
Esempio n. 2
0
        private static byte[] Decrypt(Stream data)
        {
            using (UnpackMeClient client = new UnpackMeClient(LoginInfo.URL))
            {
                client.Authenticate(LoginInfo.Username, LoginInfo.Password);
                var commands       = client.GetAvailableCommands();
                var commandName    = "DJMax *.pt decrypt";
                var decryptCommand = commands.SingleOrDefault(x => x.CommandTitle == commandName);

                var taskId = client.CreateTaskFromCommandId(decryptCommand.CommandId, data);

                TaskModel task;
                string    taskStatus;
                do
                {
                    task       = client.GetTaskById(taskId);
                    taskStatus = task.TaskStatus;
                    Console.WriteLine("Decrypt task status: " + taskStatus);
                    System.Threading.Thread.Sleep(500);
                } while (taskStatus != "completed");

                return(client.DownloadToByteArray(taskId));
            }
        }