Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

C# encrypt folder SHA512

public class EncryptionFile
    {
        public void EncryptFile(string file, string password)
        {
            byte[] bytesToBeEncrypted = File.ReadAllBytes(file);
            byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
            // Hash the password with SHA256
            passwordBytes = SHA256.Create().ComputeHash(passwordBytes);
            byte[] bytesEncrypted = CoreEncryption.AES_Encrypt(bytesToBeEncrypted, passwordBytes);
            string fileEncrypted = file;
            File.WriteAllBytes(fileEncrypted, bytesEncrypted);
        }
    }

    public class DecryptionFile
    {
        public void DecryptFile(string fileEncrypted, string password)
        {

            byte[] bytesToBeDecrypted = File.ReadAllBytes(fileEncrypted);
            byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
            passwordBytes = SHA256.Create().ComputeHash(passwordBytes);

            byte[] bytesDecrypted = CoreDecryption.AES_Decrypt(bytesToBeDecrypted, passwordBytes);

            string file = fileEncrypted;
            File.WriteAllBytes(file, bytesDecrypted);
        }
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #encrypt #folder
ADD COMMENT
Topic
Name
5+8 =