Beispiel #1
0
 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));
 }
Beispiel #2
0
        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));
        }
Beispiel #3
0
 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);
     }
 }