Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Security.Cryptography;
- using System.Text;
- using UnityEngine;
- public class GHEncryption : MonoBehaviour
- {
- private static int[] encryptionKey = new int[]
- {
- 7,
- 3,
- 2,
- 5,
- 4,
- 2,
- 5,
- 5,
- 3
- };
- public static string SimpleEncrypt(string iInput)
- {
- char[] array = iInput.ToCharArray();
- int num = GHEncryption.encryptionKey.Length;
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < array.Length; i++)
- {
- stringBuilder.Append((char)((int)array[i] + GHEncryption.encryptionKey[i % num]));
- }
- return stringBuilder.ToString();
- }
- public static string SimpleDecrypt(string iInput)
- {
- char[] array = iInput.ToCharArray();
- int num = GHEncryption.encryptionKey.Length;
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < array.Length; i++)
- {
- stringBuilder.Append((char)((int)array[i] - GHEncryption.encryptionKey[i % num]));
- }
- return stringBuilder.ToString();
- }
- public static string Md5Sum(string strToEncrypt)
- {
- HashAlgorithm hashAlgorithm = MD5.Create();
- Encoding encoding = new UTF8Encoding();
- StringBuilder stringBuilder = new StringBuilder();
- byte[] array = hashAlgorithm.ComputeHash(encoding.GetBytes(strToEncrypt));
- for (int i = 0; i < array.Length; i++)
- {
- byte b = array[i];
- stringBuilder.Append(b.ToString("x2"));
- }
- return stringBuilder.ToString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement