Skip to content

How to encrypt & decrypt a file ? #21

Discussion options

You must be logged in to vote

To encrypt and decrypt any file use : MBSecurity.MBFile static class.

Example 1 : Encrypt a file using your custom Key

string MyFilePath = "C:\\Users\\MBARK\\Desktop\\MyWorkBook.xlsx";

//Get the file bytes
byte[] fileBytes = File.ReadAllBytes(MyFilePath);

//Encrypt the file bytes
var EncryptedData = MBSecurity.MBFile.Encrypt(fileBytes);

Notes :

  • The data types returned to EncryptedData variable is MBSecurity.FileEncryptionModel
  • The Key property contains the key used in the encryption
  • The Key after the encryption will be encrypted

Example 2 : Encrypt a file without Key and IV

  • To encrypt a file without using Key and IVuse the
  • MBSecurity.MBFile.EncryptWithoutKey static method.
  • This met…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MbarkT3STO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant