Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using System.Security.Cryptography;
- using System.Diagnostics;
- namespace SzyfrowanieMD5_csharp
- {
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- txtBlock.Text = MD5(txtBox.Text);
- }
- private string MD5(string Value)
- {
- System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
- byte[] data = System.Text.Encoding.ASCII.GetBytes(Value);
- data = x.ComputeHash(data);
- string ret = "";
- for (int i = 0; i < data.Length; i++)
- ret += data[i].ToString("x2").ToLower();
- return ret;
- }
- public static string sha1encrypt(string phrase)
- {
- UTF8Encoding encoder = new UTF8Encoding();
- SHA1CryptoServiceProvider sha1hasher = new SHA1CryptoServiceProvider();
- byte[] hashedDataBytes = sha1hasher.ComputeHash(encoder.GetBytes(phrase));
- return byteArrayToString(hashedDataBytes);
- }
- public static string sha256encrypt(string phrase)
- {
- UTF8Encoding encoder = new UTF8Encoding();
- SHA256Managed sha256hasher = new SHA256Managed();
- byte[] hashedDataBytes = sha256hasher.ComputeHash(encoder.GetBytes(phrase));
- return byteArrayToString(hashedDataBytes);
- }
- public static string sha384encrypt(string phrase)
- {
- UTF8Encoding encoder = new UTF8Encoding();
- SHA384Managed sha384hasher = new SHA384Managed();
- byte[] hashedDataBytes = sha384hasher.ComputeHash(encoder.GetBytes(phrase));
- return byteArrayToString(hashedDataBytes);
- }
- public static string sha512encrypt(string phrase)
- {
- UTF8Encoding encoder = new UTF8Encoding();
- SHA512Managed sha512hasher = new SHA512Managed();
- byte[] hashedDataBytes = sha512hasher.ComputeHash(encoder.GetBytes(phrase));
- return byteArrayToString(hashedDataBytes);
- }
- public static string byteArrayToString(byte[] inputArray)
- {
- StringBuilder output = new StringBuilder("");
- for (int i = 0; i < inputArray.Length; i++)
- {
- output.Append(inputArray[i].ToString("X2"));
- }
- return output.ToString();
- }
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- txtBlock.Text = sha256encrypt(txtBox.Text);
- }
- private void Button_Click_2(object sender, RoutedEventArgs e)
- {
- Process.Start("chrome.exe");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement