473,320 Members | 1,845 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,320 software developers and data experts.

Can I somehow password-protect pre-import CSV files?

I wrote a simple VB.NET application that imports and edits CSV files.

Now I’d like to “lock” the raw (pre-import) CSV files so these cannot be
opened separately. It is not high-sensitive data, I just don’t want folks to
peek in the files.

So time-consuming encryption is not necessary, just a simple
password-to-open that I can program in my application so it internally opens
the imported CSV file would be perfect, but I can’t get it done. In fact it
seems difficult to password-protect a CSV file in any way.

The pre-import CSV’s are delivered as ZIP’s, so I thought about
password-protecting the ZIP files and importing and unzipping these within my
program, but this would seem much more challenging (if at all possible)
especially for an inexperienced programmer like me.

Any tips, pointers, ideas are highly appreciated. Thanks!
Feb 24 '07 #1
12 11036
one easy solution is to save as excel file, password protect it, delete csv
file. When you need the csv file, open the excel file and save as csv file.
"jonigr" <jo****@discussions.microsoft.comwrote in message
news:FB**********************************@microsof t.com...
>I wrote a simple VB.NET application that imports and edits CSV files.

Now I'd like to "lock" the raw (pre-import) CSV files so these cannot be
opened separately. It is not high-sensitive data, I just don't want folks
to
peek in the files.

So time-consuming encryption is not necessary, just a simple
password-to-open that I can program in my application so it internally
opens
the imported CSV file would be perfect, but I can't get it done. In fact
it
seems difficult to password-protect a CSV file in any way.

The pre-import CSV's are delivered as ZIP's, so I thought about
password-protecting the ZIP files and importing and unzipping these within
my
program, but this would seem much more challenging (if at all possible)
especially for an inexperienced programmer like me.

Any tips, pointers, ideas are highly appreciated. Thanks!

Feb 25 '07 #2
Bill, that seemed a great idea but I just saved a 295 kB CSV file as a 1451
kB XLS file: it appears the filesize increases almost 5X. That's a serious
price to pay.

Appreciate your suggestion, but still open to others that may keep the
filesize in check. Thanks.

-joni

"Bill Voorhees" wrote:
one easy solution is to save as excel file, password protect it, delete csv
file. When you need the csv file, open the excel file and save as csv file.
"jonigr" <jo****@discussions.microsoft.comwrote in message
news:FB**********************************@microsof t.com...
I wrote a simple VB.NET application that imports and edits CSV files.

Now I'd like to "lock" the raw (pre-import) CSV files so these cannot be
opened separately. It is not high-sensitive data, I just don't want folks
to
peek in the files.

So time-consuming encryption is not necessary, just a simple
password-to-open that I can program in my application so it internally
opens
the imported CSV file would be perfect, but I can't get it done. In fact
it
seems difficult to password-protect a CSV file in any way.

The pre-import CSV's are delivered as ZIP's, so I thought about
password-protecting the ZIP files and importing and unzipping these within
my
program, but this would seem much more challenging (if at all possible)
especially for an inexperienced programmer like me.

Any tips, pointers, ideas are highly appreciated. Thanks!


Feb 25 '07 #3
The reason that you cannot password protect a CSV file is because by
definition there is no place to store the password. It's a file of
"comma-separated values" for that to be recognized by any program one can't
arbitrarily declare a password is inside it somewhere.

You have two standard solutions. One is to create your own file format
which consists of a password field "plus" a csv file. Your app would know
where the password is and can check it and it would know the offset where
the CSV begins. Keep in mind that while this may stop the novice it
wouldn't stop anybody with relatively ordinary skills who might open the
file with say Notepad and notice a perfectly good CSV file a few bytes to
the right of something that looks like a password.

The other solution (as you mentioned) is to encrypt the file which would
stop most people as your app would the only one that could decrypt it. It
doesn't have to be time-consuming but obviously it would take some time.
Perhaps not much longer than it would to prompt the user for a password and
of course the users wouldn't stick the password on a post-it (tm) note on
their monitor.

"jonigr" <jo****@discussions.microsoft.comwrote in message
news:FB**********************************@microsof t.com...
>I wrote a simple VB.NET application that imports and edits CSV files.

Now I'd like to "lock" the raw (pre-import) CSV files so these cannot be
opened separately. It is not high-sensitive data, I just don't want folks
to
peek in the files.

So time-consuming encryption is not necessary, just a simple
password-to-open that I can program in my application so it internally
opens
the imported CSV file would be perfect, but I can't get it done. In fact
it
seems difficult to password-protect a CSV file in any way.

The pre-import CSV's are delivered as ZIP's, so I thought about
password-protecting the ZIP files and importing and unzipping these within
my
program, but this would seem much more challenging (if at all possible)
especially for an inexperienced programmer like me.

Any tips, pointers, ideas are highly appreciated. Thanks!

Feb 25 '07 #4
Much obliged Tom, very clear advice.

The csv + password method is just below minimum indeed.

Any encryption method perhaps you could point me to that would fit the bill?:

- CSV files
- speed over (extreme) security
- decrypt in VB.NET
- not (much) filesize increase

Thanks very much!

-joni

"Tom Leylan" wrote:
The reason that you cannot password protect a CSV file is because by
definition there is no place to store the password. It's a file of
"comma-separated values" for that to be recognized by any program one can't
arbitrarily declare a password is inside it somewhere.

You have two standard solutions. One is to create your own file format
which consists of a password field "plus" a csv file. Your app would know
where the password is and can check it and it would know the offset where
the CSV begins. Keep in mind that while this may stop the novice it
wouldn't stop anybody with relatively ordinary skills who might open the
file with say Notepad and notice a perfectly good CSV file a few bytes to
the right of something that looks like a password.

The other solution (as you mentioned) is to encrypt the file which would
stop most people as your app would the only one that could decrypt it. It
doesn't have to be time-consuming but obviously it would take some time.
Perhaps not much longer than it would to prompt the user for a password and
of course the users wouldn't stick the password on a post-it (tm) note on
their monitor.

"jonigr" <jo****@discussions.microsoft.comwrote in message
news:FB**********************************@microsof t.com...
I wrote a simple VB.NET application that imports and edits CSV files.

Now I'd like to "lock" the raw (pre-import) CSV files so these cannot be
opened separately. It is not high-sensitive data, I just don't want folks
to
peek in the files.

So time-consuming encryption is not necessary, just a simple
password-to-open that I can program in my application so it internally
opens
the imported CSV file would be perfect, but I can't get it done. In fact
it
seems difficult to password-protect a CSV file in any way.

The pre-import CSV's are delivered as ZIP's, so I thought about
password-protecting the ZIP files and importing and unzipping these within
my
program, but this would seem much more challenging (if at all possible)
especially for an inexperienced programmer like me.

Any tips, pointers, ideas are highly appreciated. Thanks!


Feb 25 '07 #5
I'm not an expert on this stuff but you can check the
System.Security.Cryptography Namespace. You may prefer a symmetric
algorithm so you can encrypt/decrypt without a lot of fuss.

That said you can also just obscure the data by encoding it in Base64.
There are methods in the Convert Class you can use. It should be fast and
while somebody might recognize it as Base64 encoding the average user
probably wouldn't. I tried it out and successfully read a CSV, converted to
Base64 and wrote it out to a new file then read that file back in and wrote
out a standard CSV again. Whichever method you choose you would do well to
search the Internet as there are dozens of examples and a few complete
implementations that you could just download and use.

Personally I wouldn't get too concerned over the speed until it is
demonstrated to actually take too long. That might happen but if the
slowest encryption method (with the highest security) isn't noticeable on
the file sizes you have then any of the faster algorithms would obviously be
fine.

Hope this helps.

"jonigr" <jo****@discussions.microsoft.comwrote in message
news:65**********************************@microsof t.com...
Much obliged Tom, very clear advice.

The csv + password method is just below minimum indeed.

Any encryption method perhaps you could point me to that would fit the
bill?:

- CSV files
- speed over (extreme) security
- decrypt in VB.NET
- not (much) filesize increase

Thanks very much!

-joni

"Tom Leylan" wrote:
>The reason that you cannot password protect a CSV file is because by
definition there is no place to store the password. It's a file of
"comma-separated values" for that to be recognized by any program one
can't
arbitrarily declare a password is inside it somewhere.

You have two standard solutions. One is to create your own file format
which consists of a password field "plus" a csv file. Your app would
know
where the password is and can check it and it would know the offset where
the CSV begins. Keep in mind that while this may stop the novice it
wouldn't stop anybody with relatively ordinary skills who might open the
file with say Notepad and notice a perfectly good CSV file a few bytes to
the right of something that looks like a password.

The other solution (as you mentioned) is to encrypt the file which would
stop most people as your app would the only one that could decrypt it.
It
doesn't have to be time-consuming but obviously it would take some time.
Perhaps not much longer than it would to prompt the user for a password
and
of course the users wouldn't stick the password on a post-it (tm) note on
their monitor.

"jonigr" <jo****@discussions.microsoft.comwrote in message
news:FB**********************************@microso ft.com...
>I wrote a simple VB.NET application that imports and edits CSV files.

Now I'd like to "lock" the raw (pre-import) CSV files so these cannot
be
opened separately. It is not high-sensitive data, I just don't want
folks
to
peek in the files.

So time-consuming encryption is not necessary, just a simple
password-to-open that I can program in my application so it internally
opens
the imported CSV file would be perfect, but I can't get it done. In
fact
it
seems difficult to password-protect a CSV file in any way.

The pre-import CSV's are delivered as ZIP's, so I thought about
password-protecting the ZIP files and importing and unzipping these
within
my
program, but this would seem much more challenging (if at all possible)
especially for an inexperienced programmer like me.

Any tips, pointers, ideas are highly appreciated. Thanks!



Feb 25 '07 #6
Hello jonigr,
Now I’d like to “lock” the raw (pre-import) CSV files so these cannot be
opened separately. It is not high-sensitive data, I just don’t want folks to
peek in the files.
You could ZIP them. ZIP archives also support password protection.
The pre-import CSV’s are delivered as ZIP’s, so I thought about
password-protecting the ZIP files and importing and unzipping these within my
program, but this would seem much more challenging (if at all possible)
especially for an inexperienced programmer like me.
The easy solution would be to call a DOS ZIP archiver (via Shell
function) and provide the required data (File name, archive name, password).

Best regards,

Martin
Feb 25 '07 #7
jonigr,
The pre-import CSV’s are delivered as ZIP’s, so I thought about
password-protecting the ZIP files and importing and unzipping these within
my
Have you considered a .NET 3.0 "Package"? Aka an Office 2007 .xlsx file?

http://msdn.microsoft.com/msdnmag/is...s/default.aspx

http://msdn2.microsoft.com/en-us/lib...packaging.aspx

http://www.microsoft.com/downloads/d...displaylang=en
..NET 3.0 & Office 2007 are adopting the "Package" as a standard file format.
What is a "Package" you ask? Its little more then a specifically formatted
Zip file. In other words its a zip file that contains a specific structure &
some specific files. Office 2007 files are packages (zip files) that contain
XML documents.

What is .NET 3.0 you ask? .NET 3.0 is a full superset of .NET 2.0 that is
included with Windows Vista. .NET 2.0 programs run unaffected as .NET 3.0
adds new namespaces & types to existing .NET 2.0 installations.
I was under the impression, but have not verified it, that you can use the
System.IO.Packaging namespace to open a plain ZIP file. Something that I
will try this morning & report back on. If System.IO.Packaging cannot read
plain zip files, you should be able to use this converter to save the xls as
an xlsx file:

http://www.microsoft.com/downloads/d...displaylang=en
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"jonigr" <jo****@discussions.microsoft.comwrote in message
news:FB**********************************@microsof t.com...
>I wrote a simple VB.NET application that imports and edits CSV files.

Now I’d like to “lock” the raw (pre-import) CSV files so these cannot be
opened separately. It is not high-sensitive data, I just don’t want folks
to
peek in the files.

So time-consuming encryption is not necessary, just a simple
password-to-open that I can program in my application so it internally
opens
the imported CSV file would be perfect, but I can’t get it done. In fact
it
seems difficult to password-protect a CSV file in any way.

The pre-import CSV’s are delivered as ZIP’s, so I thought about
password-protecting the ZIP files and importing and unzipping these within
my
program, but this would seem much more challenging (if at all possible)
especially for an inexperienced programmer like me.

Any tips, pointers, ideas are highly appreciated. Thanks!
Feb 25 '07 #8
=?Utf-8?B?am9uaWdy?= <jo****@discussions.microsoft.comwrote in
news:FB**********************************@microsof t.com:
So time-consuming encryption is not necessary, just a simple
password-to-open that I can program in my application so it internally
opens the imported CSV file would be perfect, but I can Tt get it
done. In fact it seems difficult to password-protect a CSV file in any
way.
CSVs have no password protection so you'll need to implement some sort of
security layer.

How about zipping the file with a password. Unzip to read?

You can use something like SharpZipLib to compress (very easy to use).
Feb 25 '07 #9
Allow me to address all great advice in this one post.

In following the various leads I found KB article 301070 using
System.Security.Cryptography Namespace that Tom mentioned and has code ready.
I honestly didn't go in-depth but the fast encrypted file looks like absolute
total garbage. Great! More than enough to scare the hell out of my average
user, never mind the pro hackers.

I will look into the ZIP possibilities suggested, this could be an
alternative.

Jay, thanks for mentioning the "Package" format, totally new to me.

Thank y'all, this is a very helpful group. I mark this one as solved.

-joni

"Spam Catcher" wrote:
=?Utf-8?B?am9uaWdy?= <jo****@discussions.microsoft.comwrote in
news:FB**********************************@microsof t.com:
So time-consuming encryption is not necessary, just a simple
password-to-open that I can program in my application so it internally
opens the imported CSV file would be perfect, but I canƒ Tt get it
done. In fact it seems difficult to password-protect a CSV file in any
way.

CSVs have no password protection so you'll need to implement some sort of
security layer.

How about zipping the file with a password. Unzip to read?

You can use something like SharpZipLib to compress (very easy to use).
Feb 25 '07 #10
Check dnr tv episode 53... Carl Franklin and Mark Dunn show how to gzip
and un-gzip and encrypt and decrypt text streams.

<http://www.dnrtv.com/default.aspx?showID=53>

I think this is just what you are looking for.

codeman

jonigr wrote:
I wrote a simple VB.NET application that imports and edits CSV files.

Now I’d like to “lock” the raw (pre-import) CSV files so these cannot be
opened separately. It is not high-sensitive data, I just don’t want folks to
peek in the files.

So time-consuming encryption is not necessary, just a simple
password-to-open that I can program in my application so it internally opens
the imported CSV file would be perfect, but I can’t get it done. In fact it
seems difficult to password-protect a CSV file in any way.

The pre-import CSV’s are delivered as ZIP’s, so I thought about
password-protecting the ZIP files and importing and unzipping these within my
program, but this would seem much more challenging (if at all possible)
especially for an inexperienced programmer like me.

Any tips, pointers, ideas are highly appreciated. Thanks!
Feb 25 '07 #11
=?Utf-8?B?am9uaWdy?= <jo****@discussions.microsoft.comwrote in
news:88**********************************@microsof t.com:
I will look into the ZIP possibilities suggested, this could be an
alternative.
ZIP is great - in fact ZIP encryption is quite secure too :-)
Feb 25 '07 #12
I was under the impression, but have not verified it, that you can use the
System.IO.Packaging namespace to open a plain ZIP file.
Playing with the System.IO.Packaging namespace this afternoon; I was
mistaken.

System.IO.Packaging cannot open a plain ZIP file. It needs to be a true
Package file.

However! as I suggested Office 2007 uses Packages as a native format, while
earlier versions have a converter that can be used to read & write Packages.

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.netwrote in
message news:E0**********************************@microsof t.com...
jonigr,
>The pre-import CSV’s are delivered as ZIP’s, so I thought about
password-protecting the ZIP files and importing and unzipping these
within my
Have you considered a .NET 3.0 "Package"? Aka an Office 2007 .xlsx file?

http://msdn.microsoft.com/msdnmag/is...s/default.aspx

http://msdn2.microsoft.com/en-us/lib...packaging.aspx

http://www.microsoft.com/downloads/d...displaylang=en
.NET 3.0 & Office 2007 are adopting the "Package" as a standard file
format. What is a "Package" you ask? Its little more then a specifically
formatted Zip file. In other words its a zip file that contains a specific
structure & some specific files. Office 2007 files are packages (zip
files) that contain XML documents.

What is .NET 3.0 you ask? .NET 3.0 is a full superset of .NET 2.0 that is
included with Windows Vista. .NET 2.0 programs run unaffected as .NET 3.0
adds new namespaces & types to existing .NET 2.0 installations.
I was under the impression, but have not verified it, that you can use the
System.IO.Packaging namespace to open a plain ZIP file. Something that I
will try this morning & report back on. If System.IO.Packaging cannot read
plain zip files, you should be able to use this converter to save the xls
as an xlsx file:

http://www.microsoft.com/downloads/d...displaylang=en
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"jonigr" <jo****@discussions.microsoft.comwrote in message
news:FB**********************************@microsof t.com...
>>I wrote a simple VB.NET application that imports and edits CSV files.

Now I’d like to “lock” the raw (pre-import) CSV files so these cannot be
opened separately. It is not high-sensitive data, I just don’t want folks
to
peek in the files.

So time-consuming encryption is not necessary, just a simple
password-to-open that I can program in my application so it internally
opens
the imported CSV file would be perfect, but I can’t get it done. In fact
it
seems difficult to password-protect a CSV file in any way.

The pre-import CSV’s are delivered as ZIP’s, so I thought about
password-protecting the ZIP files and importing and unzipping these
within my
program, but this would seem much more challenging (if at all possible)
especially for an inexperienced programmer like me.

Any tips, pointers, ideas are highly appreciated. Thanks!
Feb 25 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: John Victor | last post by:
In my mysql database, I've stored all the passwords using the PASSWORD() function. Now I'm running a test and need to compare the password in my php document to that saved in the database. I used...
5
by: MLH | last post by:
I'm supposed to set a password for the MySQL root user. The output of mysql_install_db instructed me to run the following commands... /usr/bin/mysqladmin -u root -h appserver password mynwewpasswd...
1
by: PerryC | last post by:
All, This should be very simple for you VB programmers, I am just a beginner and am stuck! It should be very simple... what am I not doing right? Dim PW As String PW = Me.Password If...
4
by: Neil Ginsberg | last post by:
I have ODBC linked tables to a SQL 7 database in an A2K database. The linked tables do not have the password stored in them, so the first time the user accesses them, they need to enter the SQL...
2
by: Jill Elaine | last post by:
I am building an Access 2002 frontend with linked tables to an encrypted Paradox 7 database. When I first create these linked tables, I'm asked for the password to the encrypted Paradox database,...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
5
by: scorpion53061 | last post by:
is it possible to set the database password that you can set in access for a database from a vb.net application?
8
by: Katash | last post by:
Hello, I am new to PHP and am working on a login system for my site, currently supplied passwords are passed to MySQL and stored as md5 hashes, my question is :- seeing as md5 is 1 way only what...
3
by: julianmoors | last post by:
Hey, Currently I'm writing a VB.NET/1.1 app and I need to mask the input for the password field. Does anyone know how to do this in VB? I've seen a C# example, but wouldn't know how to convert...
2
by: DarthPeePee | last post by:
Hello everyone. I am working on a Password Strength Meter and I am running into 1 problem that I would like to fix. When pressing the "Clear Password & Try Again" button, the password clears...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.