public static string Decryption(string cipher, string key, IBlockCipherPadding padding) { BlowFishEncryptor encriptor = new BlowFishEncryptor(); encriptor.SetPadding(padding); return(encriptor.Decrypt(cipher, key)); }
public static string Encryption(string plain, string key, IBlockCipherPadding padding) { BlowFishEncryptor encriptor = new BlowFishEncryptor(); encriptor.SetPadding(padding); return(encriptor.Encrypt(plain, key)); }
public static string GetCryptFileName(long oid, string fileName) { string blowfish_key = "f)y$JQM+o!s]jk9#t,ST#,c" + oid.ToString("000000000"); string cryptname = BlowFishEncryptor.Encryption(fileName, blowfish_key); char[] invalidChars = Path.GetInvalidFileNameChars(); //char[] invalidChars = new char[invalidFileChars.Length + 1]; invalidChars = (invalidChars ?? Enumerable.Empty <char>()).Concat(new[] { '+' }).ToArray(); string regex = String.Format("[{0}]", new string(invalidChars)); Regex removeInvalidChars = new Regex(regex, RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.CultureInvariant); return(removeInvalidChars.Replace(cryptname, "X")); }