Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // UnityExtensions.EncryptionExtensions
- public static string Decrypt(this string cipherString)
- {
- string result = string.Empty;
- try
- {
- byte[] array = Convert.FromBase64String(cipherString);
- EncryptionExtensions.ValidateInput(cipherString);
- EncryptionExtensions.ValidateInput(EncryptionExtensions.SecurityKey);
- byte b = array[0];
- byte b2 = array[array.Length - 1];
- byte[] array2 = new byte[(int)b2];
- int num = (int)(b2 + 1);
- Buffer.BlockCopy(array, array.Length - num, array2, 0, (int)b2);
- byte[] array3 = new byte[array.Length - 1 - (int)b2 - 1];
- Buffer.BlockCopy(array, 1, array3, 0, array3.Length);
- byte[] bytes = Encoding.UTF8.GetBytes(EncryptionExtensions.SecurityKey);
- byte[] array4 = new byte[bytes.Length + 1];
- Buffer.BlockCopy(bytes, 0, array4, 0, bytes.Length);
- array4[array4.Length - 1] = b;
- SHA1CryptoServiceProvider sHA1CryptoServiceProvider = new SHA1CryptoServiceProvider();
- byte[] key = sHA1CryptoServiceProvider.ComputeHash(array4);
- Array.Resize<byte>(ref key, 16);
- sHA1CryptoServiceProvider.Clear();
- TripleDESCryptoServiceProvider tripleDESCryptoServiceProvider = new TripleDESCryptoServiceProvider();
- tripleDESCryptoServiceProvider.Key = key;
- tripleDESCryptoServiceProvider.IV = array2;
- tripleDESCryptoServiceProvider.Mode = CipherMode.CFB;
- tripleDESCryptoServiceProvider.Padding = PaddingMode.PKCS7;
- ICryptoTransform cryptoTransform = tripleDESCryptoServiceProvider.CreateDecryptor();
- byte[] bytes2 = cryptoTransform.TransformFinalBlock(array3, 0, array3.Length);
- tripleDESCryptoServiceProvider.Clear();
- result = Encoding.UTF8.GetString(bytes2);
- }
- catch (Exception var_14_11D)
- {
- return "-1";
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement