-
-
Save sharpicx/6f3cb76e15ea33008c0ad424c393f1aa to your computer and use it in GitHub Desktop.
random
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel; | |
using System.Drawing; | |
using System.IO; | |
using System.Security.Cryptography; | |
using System.Text; | |
public class HelloWorld | |
{ | |
public static void Main(string[] args) | |
{ | |
Console.WriteLine(HelloWorld.Decrypt(Encoding.ASCII.GetString(new byte[] | |
{ | |
65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | |
80, 103, 117, 72, 103, 90, 90, 122, 54, 112, 69, 43, 116, 69, 116, 55, 77, 99, 69, 77, | |
65, 83, 113, 81, 79, 55, 104, 102, 107, 48, 53, 115, 113, 49, 111, 56, 65, 101, 79, 97, | |
83, 78, 66, 68, 112, 115, 57, 82, 113, 101, 47, 98, 109, 98, 57, 88, 104, 79, 122, 53, | |
76, 104, 72, 99, 74, 74, 110, 115, 116, 121, 121, 53, 113, 79, 52, 83, 87, 88, 78, 107, | |
88, 100, 118, 86, 55, 103, 61, 61 | |
}))); | |
} | |
public static string Decrypt(string cipherText) | |
{ | |
byte[] salt = Convert.FromBase64String(cipherText.Substring(0, 20)); | |
cipherText = cipherText.Substring(20).Replace(" ", "+"); | |
byte[] array = Convert.FromBase64String(cipherText); | |
byte[] bytes = new byte[] | |
{ | |
116, | |
101, | |
115, | |
116, | |
49, | |
50, | |
51 | |
}; | |
using (Aes aes = Aes.Create()) | |
{ | |
Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(Encoding.ASCII.GetString(bytes), salt); | |
aes.Key = rfc2898DeriveBytes.GetBytes(32); | |
aes.IV = rfc2898DeriveBytes.GetBytes(16); | |
using (MemoryStream memoryStream = new MemoryStream()) | |
{ | |
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, aes.CreateDecryptor(), CryptoStreamMode.Write)) | |
{ | |
cryptoStream.Write(array, 0, array.Length); | |
cryptoStream.Close(); | |
} | |
cipherText = Encoding.Unicode.GetString(memoryStream.ToArray()); | |
} | |
} | |
return cipherText; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment