public static string Encrypt(string cryptoMethod, string txt) { string retVal = String.Empty; try { CryptoType ct; Enum.TryParse(cryptoMethod, true, out ct); CryptoCollection cc = CryptoCollection.GetCryptoCollectionInfoByMethod(cryptoMethod); string key = genRandomText(cc.Key); string iv = genRandomText(cc.IV); string e = Encrypt(ct, txt, key, iv); int i = (int)e.FirstOrDefault(); key = String.Join(String.Empty, key.Reverse().ToArray()); iv = String.Join(String.Empty, iv.Reverse().ToArray()); if (i < e.Length) { e = e.Substring(0, i) + key + iv + e.Substring(i); } else { e += key + iv; } retVal = "[" + cc.ID + "]" + e; } catch { } return(retVal); }
public static string Encrypts(string cryptoMethod, string txt) { string retVal = String.Empty; try { CryptoType ct; Enum.TryParse(cryptoMethod, out ct); CryptoCollection cc = CryptoCollection.GetCryptoCollectionInfoByMethod(cryptoMethod); //retVal = Encrypt(cryptoMethod, txt, cc); } catch { } return(retVal); }