public static byte[] GetAdditionalData(FileStream inputFile, byte[] ephemeralPublicKey) { byte[] ciphertextLength = BitConversion.GetBytes(inputFile.Length - Constants.FileHeadersLength); byte[] magicBytes = FileHeaders.ReadMagicBytes(inputFile); byte[] formatVersion = FileHeaders.ReadFileFormatVersion(inputFile); FileHeaders.ValidateFormatVersion(formatVersion, Constants.EncryptionVersion); return(Arrays.Concat(ciphertextLength, magicBytes, formatVersion, ephemeralPublicKey)); }
public static byte[] GetAdditionalData(string inputFilePath) { byte[] magicBytes = FileHeaders.ReadMagicBytes(inputFilePath); byte[] formatVersion = FileHeaders.ReadFileFormatVersion(inputFilePath); FileHeaders.ValidateFormatVersion(inputFilePath, formatVersion, Constants.EncryptionVersion); long fileLength = FileHandling.GetFileLength(inputFilePath); int headersLength = FileHeaders.GetHeadersLength(); byte[] ciphertextLength = BitConverter.GetBytes(fileLength - headersLength); return(Utilities.ConcatArrays(magicBytes, formatVersion, ciphertextLength)); }
public static bool?IsKryptorFile(string filePath) { try { byte[] magicBytes = FileHeaders.ReadMagicBytes(filePath); return(Utilities.Compare(magicBytes, Constants.KryptorMagicBytes)); } catch (Exception ex) when(ExceptionFilters.FileAccess(ex)) { return(null); } }