Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. using System;
  2. using System.Security.Cryptography;
  3. using System.Text;
  4. using UnityEngine;
  5.  
  6. public class GHEncryption : MonoBehaviour
  7. {
  8.     private static int[] encryptionKey = new int[]
  9.     {
  10.         7,
  11.         3,
  12.         2,
  13.         5,
  14.         4,
  15.         2,
  16.         5,
  17.         5,
  18.         3
  19.     };
  20.  
  21.     public static string SimpleEncrypt(string iInput)
  22.     {
  23.         char[] array = iInput.ToCharArray();
  24.         int num = GHEncryption.encryptionKey.Length;
  25.         StringBuilder stringBuilder = new StringBuilder();
  26.         for (int i = 0; i < array.Length; i++)
  27.         {
  28.             stringBuilder.Append((char)((int)array[i] + GHEncryption.encryptionKey[i % num]));
  29.         }
  30.         return stringBuilder.ToString();
  31.     }
  32.  
  33.     public static string SimpleDecrypt(string iInput)
  34.     {
  35.         char[] array = iInput.ToCharArray();
  36.         int num = GHEncryption.encryptionKey.Length;
  37.         StringBuilder stringBuilder = new StringBuilder();
  38.         for (int i = 0; i < array.Length; i++)
  39.         {
  40.             stringBuilder.Append((char)((int)array[i] - GHEncryption.encryptionKey[i % num]));
  41.         }
  42.         return stringBuilder.ToString();
  43.     }
  44.  
  45.     public static string Md5Sum(string strToEncrypt)
  46.     {
  47.         HashAlgorithm hashAlgorithm = MD5.Create();
  48.         Encoding encoding = new UTF8Encoding();
  49.         StringBuilder stringBuilder = new StringBuilder();
  50.         byte[] array = hashAlgorithm.ComputeHash(encoding.GetBytes(strToEncrypt));
  51.         for (int i = 0; i < array.Length; i++)
  52.         {
  53.             byte b = array[i];
  54.             stringBuilder.Append(b.ToString("x2"));
  55.         }
  56.         return stringBuilder.ToString();
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement