PDA

View Full Version : Advice: how to encrypt vba code on the fly



oleneazer
09-08-2004, 07:32 PM
hello
(excuse my bad english)

i try to make a sub to encrypt the vba code when the wbook is open
something like:

Sun WorkBook_Open()
encrypt
....all the vba code in the project
En Sub

so when the user of the wbook do ALT+F11
what he is viewing looks like:


Sub TEst()
20610 9280 20610 9280 22367 9280 9222 9280 23198 21741 29204 28763
End Sub

Is it possible?

oleneazer
09-08-2004, 07:38 PM
I just realize that if the user deactivate the macro
he can see the code
so my question is stupid
I just want to hide the code to avoid the user to alter the code.
I don't want to put a password in the VBAProject
Perhaps somebody has tips to arrive to the same result of what i want to do.

Daniel Klann
09-08-2004, 09:24 PM
Hi,

Why can't you use a password? That is the most reliable and simple way of stopping someone else from changing your code. An alternative is to share your workbook (Tools, Share Workbook) as this prevents anyone from editing or viewing your code.

Hope this helps,
Daniel

Jacob Hilderbrand
09-08-2004, 10:17 PM
In VBE goto Tools | VBE Project Properties...
Select the Protection tab
Check the box for "Lock project for viewing"
Input and confirm your password
Save and close the workbook

oleneazer
09-09-2004, 02:50 AM
Because thera utilities on the net to brek VBA password
I just want to make the code unreadable

Steiner
09-09-2004, 06:29 AM
And how will the encrypted code be executed? Even if you could encrypt the whole code, you'll still need unencrypted parts to execute at least the encryption. And if the user can read this encryption code...

Zack Barresse
09-09-2004, 07:10 AM
One fact that we must all live with (for now) is that Excel is just not that secure. Nothing in this world ever is - but especially Excel! It wasn't designed that way. If you protect it, there will always be those out there who can break into it within two minutes, that's just a fact of life.

Imho, the VBA password is probably the best way to disallow users to view your code.

mark007
09-10-2004, 05:10 AM
The best way would be to compile your code to COM and run it as a COM addin if you are that worried.

:)

Jacob Hilderbrand
09-10-2004, 05:25 AM
If you just want to stop users from accidentally messing up the code, a password on the project is sufficient. For some added security you can make a COM addin like Mark suggests. If you really want better security, then don't use Excel at all. It really is not meant to be secure at all.

oleneazer
09-12-2004, 03:19 AM
So there's no way to make the code unreadable by humans eyes?
Something like

Sub Test()
XGXGX Chr(x) Chr(=) 1 WX 12 BBKBKQF
(I don't remember the ASCII code for x and =)
instead of
For x=1 to 12 Then

If the user of the workbook is not good enough with VBA
he will not spend time to try undertsanding the code

It is not possible to do a Function CASCII() (a XL4Macro)
used for have the ascii code of all characters?

And then coding the VBA Code with replacing
all the characters by their ascii code?

Daniel Klann
09-12-2004, 07:32 PM
Hi,

As has been mentioned several times, this idea is not practical. You would need an un-encrypted procedure that you would use to encrypt/decrypt the rest of your code. Anyone with a little bit of VBA knowledge would easily be able to work out how to decrypt your project. Even if you could get your idea to work it there are so many potential problems that no-one in their right mind would bother with this.

To summarise (what seems to have been mentioned several times):-

Either:-

1) password protect your VBA project. This is the method that the rest of us use to protect our standard Excel files. The password hackers aren't free (at least I've never seen one that's free) and the majority of people on this planet won't try and rip you off.

If a VBA project password is not enough then:-

2) create a COM add-in using VB6, VC++, Office Developer, etc.

Regards,
Daniel

XL-Dennis
09-13-2004, 12:20 AM
Hi guys :hi:

Let's face it:

#1 If we want to keep a a secret secret then don't user any computer at all.

#2 Over 95 % of all Excel-users are not aware of the VB-editor and hardly understand
what an xla-file is about. Those that would like to decompile / reverse engineering
will find their ways anyway.

#3 Most free/ commercial add-ins rely on common code, i e wellknown code with a
personal twist on it.

#4 Protecting the VBA-project prevent us from updating modules later. If we ship 500 copies of a tool within a company and we need to update it then the only way to update it will be to replace it...

#5 Selling a commercial add-in should be based on:
No shareware-version available and offer some kind of money-guarantee.

Finally, put the hours to get a reliable and stable solution instead and worry less about this kind of issues ;)

Kind regards,
Dennis

oleneazer
09-13-2004, 01:14 AM
I work with Office 2K Small Business Edition
My employer hasn't got VB6, VC++, Office Developer.
Is there any freewares wich can replace these softwares:
VB6, VC++, Office Developer?
Where on the net can I find sites about COM and compiling VBA project
I search in Google and I don't find tips about this.

Thank you.

(and apologises for my english)

XL-Dennis
09-13-2004, 01:19 AM
Is there any freewares wich can replace these softwares:

No



Where on the net can I find sites about COM and compiling VBA project

You find several KB-articles here:
http://www.excelkb.com/article.aspx?id=10008

But again - Consider my previous post.

mark007
09-13-2004, 02:47 AM
Ypu can get VB6 very cheaply on ebay these days - Visual Studio 6 in fact too.