public static void EncryptFile(FileInfo file, byte[] key, byte[] salt) { if (file == null || !file.Exists) { throw new FileNotFoundException(); } var bytes = File.ReadAllBytes(file.FullName); using (var fileStream = new FileStream(file.FullName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { var cipherText = WeakSymmetricEncryption.Encrypt(bytes, key, salt); fileStream.Write(cipherText, 0, cipherText.Length); } file.MoveTo(Path.Combine(file.Directory.FullName, file.Name + ".falsecrypt")); }
public static byte[] EncryptMessage(byte[] secretMessage, string password) { var data = WeakPasswordDerivation.DerivePassword(password); return(WeakSymmetricEncryption.Encrypt(secretMessage, data.Key, data.Salt)); }
public static byte[] EncryptMessage(byte[] secretMessage, byte[] key, byte[] nonSecretPayload) { return(WeakSymmetricEncryption.Encrypt(secretMessage, key, nonSecretPayload)); }
public static byte[] EncryptMessage(byte[] secretMessage, byte[] key) { return(WeakSymmetricEncryption.Encrypt(secretMessage, key, null)); }