2012-03-17 2 views
0

어쩌면 도움이 될만한가요? 나는 매우 혼란 스럽다. XOR 암호화 클래스를 복사하여 다운로드 링크를 내 웹 사이트에서 호스팅되는 Minecraft Mod Installer .exe에 암호화했습니다. 그러나 다음 코드를 작성할 때 텍스트 입력이 적절한 Uri가 아니기 때문에 항상 오류가 발생합니다. 이 일을 할 수있는 방법이 있습니까? 사전에XOR을 사용하여 링크 암호화 다운로드

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 
using System.Diagnostics; 
using System.IO; 
using System.Net; 

    private void startButton_Click(object sender, EventArgs e) 
    { 
     startButton.Enabled = false; 
     WebClient client = new WebClient(); 
     client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); 
     client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted); 
     client.DownloadDataAsync(new Uri(EncryptorDecryptor.EncryptDecrypt("8a33b8a537d4e17ec4ac7041df43d892821c16dc15cf84fb33a672ab76c72119126f9c4849cf55423b0112c4b4")), Path.GetTempPath() + "mcmodinstaller.exe"); 
    } 

    void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) 
    { 
     MessageBox.Show("Successful!", 
     "Download", 
     MessageBoxButtons.OK, 
     MessageBoxIcon.Information); 

     Process.Start(Path.GetTempPath() + "mcmodinstaller.exe"); 
     startButton.Enabled = true; 
    } 
      void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) 
    { 
     downloadBar.Maximum = (int)e.TotalBytesToReceive/100; 
     downloadBar.Value = (int)e.BytesReceived/100; 
    } 
    public static class EncryptorDecryptor 
    { 
     public static int key = 3; 

     public static string EncryptDecrypt(string textToEncrypt) 
     { 
      StringBuilder inSb = new StringBuilder(textToEncrypt); 
      StringBuilder outSb = new StringBuilder(textToEncrypt.Length); 
      char c; 
      for (int i = 0; i < textToEncrypt.Length; i++) 
      { 
       c = inSb[i]; 
       c = (char)(c^key); 
       outSb.Append(c); 
      } 
      return outSb.ToString(); 
     } 
    } 
    } 

감사합니다 아래 SSCCE, 나는 C#을 매우 새로 온 사람이 내 첫번째 진짜 프로젝트입니다.

+0

SSCCE를 주면 사물을 추측하지 마십시오. –

+0

URL을 추가했습니다. (메시지가 너무 짧음) – ShredderCamflap

답변

0

어디에서 8a33b8a537d4e17ec4ac7041df43d892821c16dc15cf84fb33a672ab76c72119126f9c4849cf55423b0112c4b4을 받았습니까? '3'의 지정된 키 디코더를 통해 실행

준다 아니오

; 0ab0gf4 b47g7g:;22g2; e0b4b4 1225:77 67032`a

분명히 유효한 URI 같은 것도. 나는 (비트에서 16 진수로 값을 변환하는 것처럼) 현명한 뭔가를 얻을 수 있는지 확인하는 몇 가지 빠른 것들을 시도했지만 합리적인 아무것도 나타납니다.

C#을 처음 접했을 때 이것이 처음 실제 프로젝트 인 경우 훨씬 더 쉽게 조각으로 나눠야합니다. 문자열을 가져 와서 EncryptorDecryptor으로 인코딩 한 다음 결과를 디코딩하여 동일한 값을 얻으십시오. 그런 다음 암호화를 제쳐두고 사이트에서 정상 파일을 다운로드 할 수 있는지 확인하십시오. 둘 다 일할 때 (그리고 그들이 어떻게 작동하고 더 중요한지 이해한다면, 그들이 실패했을 때 이 어떻게 행동하는지))는 두 가지를 결합합니다.

+0

도움을 주셔서 감사합니다. 당신은 더 단순한 것에 대해 옳았습니다. 링크를 암호화하는 대신에, 실제로 얻은 코드에 대해 많이 알지 못하기 때문에, 저는 실행 파일을 난독화할 것입니다. – ShredderCamflap