C# Класс StreamCryptor.Cryptor

Class to encrypt and decrypt files with use of stream. Using: libsodium and protobuf-net.
Показать файл Открыть проект

Открытые методы

Метод Описание
DecryptFileWithStream ( Sodium.KeyPair keyPair, string inputFile, string outputFolder, bool overWrite = false ) : string

Decrypts a file with libsodium and protobuf-net.

DecryptFileWithStream ( byte recipientPrivateKey, string inputFile, string outputFolder, bool overWrite = false ) : string

Decrypts a file with libsodium and protobuf-net.

DecryptFileWithStreamAsync ( Sodium.KeyPair keyPair, string inputFile, IProgress decryptionProgress = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Decrypts a file asynchron into memory with libsodium and protobuf-net.

This method can throw an OutOfMemoryException when there is not enough ram to hold the DecryptedFile!

DecryptFileWithStreamAsync ( byte recipientPrivateKey, string inputFile, IProgress decryptionProgress = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Decrypts a file asynchron into memory with libsodium and protobuf-net.

This method can throw an OutOfMemoryException when there is not enough ram to hold the DecryptedFile!

DecryptFileWithStreamAsync ( Sodium.KeyPair keyPair, string inputFile, string outputFolder, IProgress decryptionProgress = null, bool overWrite = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Decrypts a file asynchron with libsodium and protobuf-net.

DecryptFileWithStreamAsync ( byte recipientPrivateKey, string inputFile, string outputFolder, IProgress decryptionProgress = null, bool overWrite = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Decrypts a file asynchron with libsodium and protobuf-net.

This method needs a revision.

DecryptMemoryStreamAsync ( byte recipientPrivateKey, MemoryStream inputStream, IProgress decryptionProgress = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Decrypts a memory stream asynchron into memory with libsodium and protobuf-net.

This method can throw an OutOfMemoryException when there is not enough ram to hold the DecryptedFile!

EncrypMemoryStreamAsync ( byte senderPrivateKey, byte senderPublicKey, byte recipientPublicKey, string filename, MemoryStream inputStream, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false, IProgress encryptionProgress = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Encrypts a file asynchron with libsodium and protobuf-net.

EncryptFileWithStream ( Sodium.KeyPair senderKeyPair, byte recipientPublicKey, string inputFile, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false ) : string

Encrypts a file with libsodium and protobuf-net.

The outputFolder is equal to the inputFolder.

EncryptFileWithStream ( Sodium.KeyPair senderKeyPair, string inputFile, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false ) : string

(Self)Encrypts a file with libsodium and protobuf-net.

The outputFolder is equal to the inputFolder.

EncryptFileWithStream ( byte senderPrivateKey, byte senderPublicKey, byte recipientPublicKey, string inputFile, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false ) : string

Encrypts a file with libsodium and protobuf-net.

EncryptFileWithStreamAsync ( Sodium.KeyPair senderKeyPair, byte recipientPublicKey, string inputFile, IProgress encryptionProgress = null, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Encrypts a file asynchron with libsodium and protobuf-net.

The outputFolder is equal to the inputFolder.

EncryptFileWithStreamAsync ( Sodium.KeyPair senderKeyPair, string inputFile, IProgress encryptionProgress = null, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task

(Self)Encrypts a file asynchron with libsodium and protobuf-net.

The outputFolder is equal to the inputFolder.

EncryptFileWithStreamAsync ( byte senderPrivateKey, byte senderPublicKey, byte recipientPublicKey, string inputFile, IProgress encryptionProgress = null, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Encrypts a file asynchron with libsodium and protobuf-net.

Приватные методы

Метод Описание
EncryptFileChunk ( byte unencryptedChunk, int chunkNumber, byte baseNonce, byte ephemeralKey, bool isLast ) : EncryptedFileChunk

Encrypts a file chunk.

GetChunkNonce ( byte baseNonce, int chunkNumber, bool isLastChunkInStream = false ) : byte[]

Generates an accumulated nonce.

ValidateKeyPair ( Sodium.KeyPair keyPair ) : bool

Checks a keypair for the right length.

Описание методов

DecryptFileWithStream() публичный статический Метод

Decrypts a file with libsodium and protobuf-net.
public static DecryptFileWithStream ( Sodium.KeyPair keyPair, string inputFile, string outputFolder, bool overWrite = false ) : string
keyPair Sodium.KeyPair The KeyPair to decrypt the ephemeralKey.
inputFile string An encrypted file.
outputFolder string There the decrypted file will be stored.
overWrite bool Overwrite the output file if it exist.
Результат string

DecryptFileWithStream() публичный статический Метод

Decrypts a file with libsodium and protobuf-net.
public static DecryptFileWithStream ( byte recipientPrivateKey, string inputFile, string outputFolder, bool overWrite = false ) : string
recipientPrivateKey byte A 32 byte private key.
inputFile string An encrypted file.
outputFolder string There the decrypted file will be stored.
overWrite bool Overwrite the output file if it exist.
Результат string

DecryptFileWithStreamAsync() публичный статический Метод

Decrypts a file asynchron into memory with libsodium and protobuf-net.
This method can throw an OutOfMemoryException when there is not enough ram to hold the DecryptedFile!
public static DecryptFileWithStreamAsync ( Sodium.KeyPair keyPair, string inputFile, IProgress decryptionProgress = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task
keyPair Sodium.KeyPair The KeyPair to decrypt the ephemeralKey.
inputFile string An encrypted file.
decryptionProgress IProgress StreamCryptorTaskAsyncProgress object.
cancellationToken CancellationToken Token to request task cancellation.
Результат Task

DecryptFileWithStreamAsync() публичный статический Метод

Decrypts a file asynchron into memory with libsodium and protobuf-net.
This method can throw an OutOfMemoryException when there is not enough ram to hold the DecryptedFile!
public static DecryptFileWithStreamAsync ( byte recipientPrivateKey, string inputFile, IProgress decryptionProgress = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task
recipientPrivateKey byte A 32 byte private key.
inputFile string An encrypted file.
decryptionProgress IProgress StreamCryptorTaskAsyncProgress object.
cancellationToken CancellationToken Token to request task cancellation.
Результат Task

DecryptFileWithStreamAsync() публичный статический Метод

Decrypts a file asynchron with libsodium and protobuf-net.
public static DecryptFileWithStreamAsync ( Sodium.KeyPair keyPair, string inputFile, string outputFolder, IProgress decryptionProgress = null, bool overWrite = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task
keyPair Sodium.KeyPair The KeyPair to decrypt the ephemeralKey.
inputFile string An encrypted file.
outputFolder string There the decrypted file will be stored.
decryptionProgress IProgress StreamCryptorTaskAsyncProgress object.
overWrite bool Overwrite the output file if it exist.
cancellationToken CancellationToken Token to request task cancellation.
Результат Task

DecryptFileWithStreamAsync() публичный статический Метод

Decrypts a file asynchron with libsodium and protobuf-net.
This method needs a revision.
public static DecryptFileWithStreamAsync ( byte recipientPrivateKey, string inputFile, string outputFolder, IProgress decryptionProgress = null, bool overWrite = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task
recipientPrivateKey byte A 32 byte private key.
inputFile string An encrypted file.
outputFolder string There the decrypted file will be stored.
decryptionProgress IProgress StreamCryptorTaskAsyncProgress object.
overWrite bool Overwrite the output file if it exist.
cancellationToken CancellationToken Token to request task cancellation.
Результат Task

DecryptMemoryStreamAsync() публичный статический Метод

Decrypts a memory stream asynchron into memory with libsodium and protobuf-net.
This method can throw an OutOfMemoryException when there is not enough ram to hold the DecryptedFile!
public static DecryptMemoryStreamAsync ( byte recipientPrivateKey, MemoryStream inputStream, IProgress decryptionProgress = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task
recipientPrivateKey byte A 32 byte private key.
inputStream System.IO.MemoryStream An encrypted MemoryStream.
decryptionProgress IProgress StreamCryptorTaskAsyncProgress object.
cancellationToken CancellationToken Token to request task cancellation.
Результат Task

EncrypMemoryStreamAsync() публичный статический Метод

Encrypts a file asynchron with libsodium and protobuf-net.
public static EncrypMemoryStreamAsync ( byte senderPrivateKey, byte senderPublicKey, byte recipientPublicKey, string filename, MemoryStream inputStream, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false, IProgress encryptionProgress = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task
senderPrivateKey byte A 32 byte private key.
senderPublicKey byte A 32 byte public key.
recipientPublicKey byte A 32 byte public key.
filename string The file name.
inputStream System.IO.MemoryStream The input stream.
outputFolder string There the encrypted file will be stored, if this is null the input directory is used.
fileExtension string Set a custom file extenstion: .whatever
maskFileName bool Replaces the filename with some random name.
encryptionProgress IProgress StreamCryptorTaskAsyncProgress object.
cancellationToken CancellationToken Token to request task cancellation.
Результат Task

EncryptFileWithStream() публичный статический Метод

Encrypts a file with libsodium and protobuf-net.
The outputFolder is equal to the inputFolder.
public static EncryptFileWithStream ( Sodium.KeyPair senderKeyPair, byte recipientPublicKey, string inputFile, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false ) : string
senderKeyPair Sodium.KeyPair The senders keypair.
recipientPublicKey byte A 32 byte public key.
inputFile string The input file.
outputFolder string There the encrypted file will be stored, if this is null the input directory is used.
fileExtension string Set a custom file extenstion: .whatever
maskFileName bool Replaces the filename with some random name.
Результат string

EncryptFileWithStream() публичный статический Метод

(Self)Encrypts a file with libsodium and protobuf-net.
The outputFolder is equal to the inputFolder.
public static EncryptFileWithStream ( Sodium.KeyPair senderKeyPair, string inputFile, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false ) : string
senderKeyPair Sodium.KeyPair The senders keypair.
inputFile string The input file.
outputFolder string There the encrypted file will be stored, if this is null the input directory is used.
fileExtension string Set a custom file extenstion: .whatever
maskFileName bool Replaces the filename with some random name.
Результат string

EncryptFileWithStream() публичный статический Метод

Encrypts a file with libsodium and protobuf-net.
public static EncryptFileWithStream ( byte senderPrivateKey, byte senderPublicKey, byte recipientPublicKey, string inputFile, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false ) : string
senderPrivateKey byte A 32 byte private key.
senderPublicKey byte A 32 byte public key.
recipientPublicKey byte A 32 byte public key.
inputFile string The input file.
outputFolder string There the encrypted file will be stored, if this is null the input directory is used.
fileExtension string Set a custom file extenstion: .whatever
maskFileName bool Replaces the filename with some random name.
Результат string

EncryptFileWithStreamAsync() публичный статический Метод

Encrypts a file asynchron with libsodium and protobuf-net.
The outputFolder is equal to the inputFolder.
public static EncryptFileWithStreamAsync ( Sodium.KeyPair senderKeyPair, byte recipientPublicKey, string inputFile, IProgress encryptionProgress = null, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task
senderKeyPair Sodium.KeyPair The senders keypair.
recipientPublicKey byte A 32 byte public key.
inputFile string The input file.
encryptionProgress IProgress StreamCryptorTaskAsyncProgress object.
outputFolder string
fileExtension string Set a custom file extenstion: .whatever
maskFileName bool Replaces the filename with some random name.
cancellationToken CancellationToken Token to request task cancellation.
Результат Task

EncryptFileWithStreamAsync() публичный статический Метод

(Self)Encrypts a file asynchron with libsodium and protobuf-net.
The outputFolder is equal to the inputFolder.
public static EncryptFileWithStreamAsync ( Sodium.KeyPair senderKeyPair, string inputFile, IProgress encryptionProgress = null, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task
senderKeyPair Sodium.KeyPair The senders keypair.
inputFile string The input file.
encryptionProgress IProgress StreamCryptorTaskAsyncProgress object.
outputFolder string
fileExtension string Set a custom file extenstion: .whatever
maskFileName bool Replaces the filename with some random name.
cancellationToken CancellationToken Token to request task cancellation.
Результат Task

EncryptFileWithStreamAsync() публичный статический Метод

Encrypts a file asynchron with libsodium and protobuf-net.
public static EncryptFileWithStreamAsync ( byte senderPrivateKey, byte senderPublicKey, byte recipientPublicKey, string inputFile, IProgress encryptionProgress = null, string outputFolder = null, string fileExtension = DEFAULT_FILE_EXTENSION, bool maskFileName = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task
senderPrivateKey byte A 32 byte private key.
senderPublicKey byte A 32 byte public key.
recipientPublicKey byte A 32 byte public key.
inputFile string The input file.
encryptionProgress IProgress StreamCryptorTaskAsyncProgress object.
outputFolder string There the encrypted file will be stored, if this is null the input directory is used.
fileExtension string Set a custom file extenstion: .whatever
maskFileName bool Replaces the filename with some random name.
cancellationToken CancellationToken Token to request task cancellation.
Результат Task