473,383 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Using Insight Article on AES encyption for Excel File

<Moved from the insight article located at
home > topics > microsoft access / vba > insights > aes encryption algorithm for vba and vbscript >


I have a question regarding these algorithms. I've been looking for a solution to encrypt exported spreadsheets from MS Access in order send them to another party where he would unencrypt and import the spreadsheet back to MS ACCESS. I tried the codes you posted. It seems to work well with text files but not with xls files. the file i get after encryption and unencryption seems to be corupted. If you can guide me in solving my problem, i would appreciated.
Feb 12 '17 #1

✓ answered by zmbd

mihaimdinca,
Before we dig into extending this code I would suggest using the native Office 2007 or newer encryption.

For most things the encryption in Office-2007 and newer is usually enough to protect the file contents - if you go this route make sure to use the "*.xlsx" format as it uses the newer security providers. If you use the 2003 *.XLS office files the encryption used there is much weaker and has some known exploits.

This is the part of what I've stripped out of a native Excel2013 encrypted file. As you can see, this file is using a decent encryption "out of the box"
AES
16bit blocks
256bit key
- maybe not military grade; however, it should do for the average user.

Expand|Select|Wrap|Line Numbers
  1. <encryption xmlns="http://schemas.microsoft.com/office/2006/encryption"
  2. xmlns:p="http://schemas.microsoft.com/office/2006/keyEncryptor/password"
  3. xmlns:c="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate">
  4. <keyData saltSize="16" 
  5.    blockSize="16" 
  6.    keyBits="256" 
  7.    hashSize="64" 
  8.    cipherAlgorithm="AES"
  9.    cipherChaining="ChainingModeCBC"
  10.    hashAlgorithm="SHA512"

No matter what you use for encryption, the password is everything. With an 11 character mixed-case-alphanumeric-symbol password it will take a fairly significant length of time to brute-force the password ( https://www.grc.com/haystack.htm - for example using "1!W@r1(hmAn" as a password would take around 1.8 years with a fairly massive CPU or array which most people do not have so you're looking at a century to brute force the password ) at which point the data most likely isn't worth protecting.

Of course, if you need something a bit stronger then we can go from there...

1 2218
zmbd
5,501 Expert Mod 4TB
mihaimdinca,
Before we dig into extending this code I would suggest using the native Office 2007 or newer encryption.

For most things the encryption in Office-2007 and newer is usually enough to protect the file contents - if you go this route make sure to use the "*.xlsx" format as it uses the newer security providers. If you use the 2003 *.XLS office files the encryption used there is much weaker and has some known exploits.

This is the part of what I've stripped out of a native Excel2013 encrypted file. As you can see, this file is using a decent encryption "out of the box"
AES
16bit blocks
256bit key
- maybe not military grade; however, it should do for the average user.

Expand|Select|Wrap|Line Numbers
  1. <encryption xmlns="http://schemas.microsoft.com/office/2006/encryption"
  2. xmlns:p="http://schemas.microsoft.com/office/2006/keyEncryptor/password"
  3. xmlns:c="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate">
  4. <keyData saltSize="16" 
  5.    blockSize="16" 
  6.    keyBits="256" 
  7.    hashSize="64" 
  8.    cipherAlgorithm="AES"
  9.    cipherChaining="ChainingModeCBC"
  10.    hashAlgorithm="SHA512"

No matter what you use for encryption, the password is everything. With an 11 character mixed-case-alphanumeric-symbol password it will take a fairly significant length of time to brute-force the password ( https://www.grc.com/haystack.htm - for example using "1!W@r1(hmAn" as a password would take around 1.8 years with a fairly massive CPU or array which most people do not have so you're looking at a century to brute force the password ) at which point the data most likely isn't worth protecting.

Of course, if you need something a bit stronger then we can go from there...
Feb 14 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Micke | last post by:
Hi, I'm trying to open an Excel file from an aspx with following code: Imports Excel = Microsoft.Office.Interop.Excel Dim oExcel As New Excel.Application Dim oBooks As Excel.Workbooks...
27
by: jeniffer | last post by:
I need to create an excel file through a C program and then to populate it.How can it be done?
3
by: jnb0012 | last post by:
Can anyone help with this? Here is the code I am using. The problem is, where it checks if a file exists, it always goes to else. Even if the file is there, it won't open the file, goes straight...
0
by: =?Utf-8?B?Tml5YXpp?= | last post by:
Hi all, Does anyone know how to embed the Excel file in VB.NET 2005 Resources? Here is what I am doing at the moment: 1) In my VB.NET 2005 project code I load the excel with it path into...
4
by: urprettyfriend | last post by:
Hi, I have an Excel file with 400 rows of old values and the corresponding new values. My table currently has 10 columns out of which 3 columns use the old value specified in the excel file. I...
9
by: Looch | last post by:
Was hoping I could get some insight on this. I added a text box and command button to a web page and added the code in the .vb file to open an existing Excel file based on what was typed in the...
2
by: RZ15 | last post by:
Hi, I am trying to use the transferspreadsheet command to transfer a table into an excel file i have. I'm using the following code: Private Sub cmdOK_Click() 'Run Make-Table query...
1
by: Hema Suresh | last post by:
Hi all I am going mad of this problem Please someone help me I used vb and excel to save a database I used oXLBook.Save "To save the file" oXLBook.Close "To close it properly ...
6
by: sankar2011 | last post by:
This is for the concept. So import statements/package statements have been avoided. Also only the necessary methods are given. Search **** for the comments Courtesy Effective Java by Joshua...
0
by: Brian Johnson | last post by:
Hi all I've used Paul Sadowski's CDO email script for some time via a remote SMTP server. It works really well. Up till now I've been adding a .pdf attachment and that's worked well too. Now...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.