public static string CutStringProlongSymbol(string originalVal, int cutLength) { if (originalVal.Length <= cutLength) { return(originalVal); } return(TextUtility.CutLeft(originalVal, cutLength) + TextUtility.PROLONG_SYMBOL); }
public static string CutStringProlongSymbol(string originalVal, int cutLength, string prolongSymbol) { if (string.IsNullOrEmpty(prolongSymbol)) { prolongSymbol = TextUtility.PROLONG_SYMBOL; } return(TextUtility.CutLeft(originalVal, cutLength) + prolongSymbol); }
public static string Encrypt(string plainText, string cipherkey) { cipherkey = TextUtility.CutLeft(cipherkey, 0x20); cipherkey = cipherkey.PadRight(0x20, ' '); ICryptoTransform transform = new RijndaelManaged { Key = Encoding.UTF8.GetBytes(cipherkey.Substring(0, 0x20)), IV = Keys }.CreateEncryptor(); byte[] bytes = Encoding.UTF8.GetBytes(plainText); return(Convert.ToBase64String(transform.TransformFinalBlock(bytes, 0, bytes.Length))); }
public static byte[] EncryptBuffer(byte[] plainText, string cipherkey) { cipherkey = TextUtility.CutLeft(cipherkey, 0x20); cipherkey = cipherkey.PadRight(0x20, ' '); RijndaelManaged managed = new RijndaelManaged { Key = Encoding.UTF8.GetBytes(cipherkey.Substring(0, 0x20)), IV = Keys }; return(managed.CreateEncryptor().TransformFinalBlock(plainText, 0, plainText.Length)); }
public static byte[] EncryptBuffer(byte[] plainText, string cipherkey) { cipherkey = TextUtility.CutLeft(cipherkey, 32); cipherkey = cipherkey.PadRight(32, ' '); RijndaelManaged rijndaelManaged = new RijndaelManaged(); rijndaelManaged.Key = Encoding.UTF8.GetBytes(cipherkey.Substring(0, 32)); rijndaelManaged.IV = Keys; RijndaelManaged rijndaelManaged2 = rijndaelManaged; return(rijndaelManaged2.CreateEncryptor().TransformFinalBlock(plainText, 0, plainText.Length)); }
public static string Encrypt(string plainText, string cipherkey) { cipherkey = TextUtility.CutLeft(cipherkey, 32); cipherkey = cipherkey.PadRight(32, ' '); RijndaelManaged rijndaelManaged = new RijndaelManaged(); rijndaelManaged.Key = Encoding.UTF8.GetBytes(cipherkey.Substring(0, 32)); rijndaelManaged.IV = Keys; ICryptoTransform cryptoTransform = rijndaelManaged.CreateEncryptor(); byte[] bytes = Encoding.UTF8.GetBytes(plainText); return(Convert.ToBase64String(cryptoTransform.TransformFinalBlock(bytes, 0, bytes.Length))); }
public static string Encrypt(string encryptString, string encryptKey) { encryptKey = TextUtility.CutLeft(encryptKey, 8); encryptKey = encryptKey.PadRight(8, ' '); byte[] bytes = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8)); byte[] keys = Keys; byte[] buffer = Encoding.UTF8.GetBytes(encryptString); DESCryptoServiceProvider provider = new DESCryptoServiceProvider(); MemoryStream stream = new MemoryStream(); CryptoStream stream2 = new CryptoStream(stream, provider.CreateEncryptor(bytes, keys), CryptoStreamMode.Write); stream2.Write(buffer, 0, buffer.Length); stream2.FlushFinalBlock(); return(Convert.ToBase64String(stream.ToArray())); }
public static byte[] DecryptBuffer(byte[] cipherText, string cipherkey) { try { cipherkey = TextUtility.CutLeft(cipherkey, 0x20); cipherkey = cipherkey.PadRight(0x20, ' '); RijndaelManaged managed = new RijndaelManaged { Key = Encoding.UTF8.GetBytes(cipherkey), IV = Keys }; return(managed.CreateDecryptor().TransformFinalBlock(cipherText, 0, cipherText.Length)); } catch { return(null); } }
public static byte[] DecryptBuffer(byte[] cipherText, string cipherkey) { try { cipherkey = TextUtility.CutLeft(cipherkey, 32); cipherkey = cipherkey.PadRight(32, ' '); RijndaelManaged rijndaelManaged = new RijndaelManaged(); rijndaelManaged.Key = Encoding.UTF8.GetBytes(cipherkey); rijndaelManaged.IV = Keys; RijndaelManaged rijndaelManaged2 = rijndaelManaged; return(rijndaelManaged2.CreateDecryptor().TransformFinalBlock(cipherText, 0, cipherText.Length)); } catch { return(null); } }
public static string Decrypt(string cipherText, string cipherkey) { try { cipherkey = TextUtility.CutLeft(cipherkey, 0x20); cipherkey = cipherkey.PadRight(0x20, ' '); ICryptoTransform transform = new RijndaelManaged { Key = Encoding.UTF8.GetBytes(cipherkey), IV = Keys }.CreateDecryptor(); byte[] inputBuffer = Convert.FromBase64String(cipherText); byte[] bytes = transform.TransformFinalBlock(inputBuffer, 0, inputBuffer.Length); return(Encoding.UTF8.GetString(bytes)); } catch { return(""); } }
public static string Decrypt(string cipherText, string cipherkey) { try { cipherkey = TextUtility.CutLeft(cipherkey, 32); cipherkey = cipherkey.PadRight(32, ' '); RijndaelManaged rijndaelManaged = new RijndaelManaged(); rijndaelManaged.Key = Encoding.UTF8.GetBytes(cipherkey); rijndaelManaged.IV = Keys; ICryptoTransform cryptoTransform = rijndaelManaged.CreateDecryptor(); byte[] array = Convert.FromBase64String(cipherText); byte[] bytes = cryptoTransform.TransformFinalBlock(array, 0, array.Length); return(Encoding.UTF8.GetString(bytes)); } catch { return(""); } }
public static byte[] DecryptBuffer(byte[] cipherText, string cipherkey) { byte[] result; try { cipherkey = TextUtility.CutLeft(cipherkey, 32); cipherkey = cipherkey.PadRight(32, ' '); RijndaelManaged rijndaelManaged = new RijndaelManaged { Key = Encoding.UTF8.GetBytes(cipherkey), IV = AES.Keys }; result = rijndaelManaged.CreateDecryptor().TransformFinalBlock(cipherText, 0, cipherText.Length); } catch { result = null; } return(result); }
public static string Decrypt(string decryptString, string decryptKey) { try { decryptKey = TextUtility.CutLeft(decryptKey, 8); decryptKey = decryptKey.PadRight(8, ' '); byte[] bytes = Encoding.UTF8.GetBytes(decryptKey); byte[] keys = Keys; byte[] buffer = Convert.FromBase64String(decryptString); DESCryptoServiceProvider provider = new DESCryptoServiceProvider(); MemoryStream stream = new MemoryStream(); CryptoStream stream2 = new CryptoStream(stream, provider.CreateDecryptor(bytes, keys), CryptoStreamMode.Write); stream2.Write(buffer, 0, buffer.Length); stream2.FlushFinalBlock(); return(Encoding.UTF8.GetString(stream.ToArray())); } catch { return(""); } }
public static string Decrypt(string cipherText, string cipherkey) { string result; try { cipherkey = TextUtility.CutLeft(cipherkey, 32); cipherkey = cipherkey.PadRight(32, ' '); ICryptoTransform cryptoTransform = new RijndaelManaged { Key = Encoding.UTF8.GetBytes(cipherkey), IV = AES.Keys }.CreateDecryptor(); byte[] array = Convert.FromBase64String(cipherText); byte[] bytes = cryptoTransform.TransformFinalBlock(array, 0, array.Length); result = Encoding.UTF8.GetString(bytes); } catch { result = ""; } return(result); }
public static string Decrypt(string decryptString, string decryptKey) { string result; try { decryptKey = TextUtility.CutLeft(decryptKey, 8); decryptKey = decryptKey.PadRight(8, ' '); byte[] bytes = Encoding.UTF8.GetBytes(decryptKey); byte[] keys = DES.Keys; byte[] array = Convert.FromBase64String(decryptString); DESCryptoServiceProvider dESCryptoServiceProvider = new DESCryptoServiceProvider(); MemoryStream memoryStream = new MemoryStream(); CryptoStream cryptoStream = new CryptoStream(memoryStream, dESCryptoServiceProvider.CreateDecryptor(bytes, keys), CryptoStreamMode.Write); cryptoStream.Write(array, 0, array.Length); cryptoStream.FlushFinalBlock(); result = Encoding.UTF8.GetString(memoryStream.ToArray()); } catch { result = ""; } return(result); }