M A
asked on
Encrypt a column in Excel
I want to VBA code to encrypt the password/serial number saved in a column with a specific number.
for example if password is abc I will add a number to it I want to save it as abc+that number not the real password.
When I click on decrypt I want a popup to enter the number I added while saving.
Finally remove the number should give the correct passwords
for example if password is abc I will add a number to it I want to save it as abc+that number not the real password.
When I click on decrypt I want a popup to enter the number I added while saving.
Finally remove the number should give the correct passwords
Just adding a number isn't going to make it that secure, if you always add 4 numbers then someone can spot the pattern If you don't how will Excel know the original number?
ASKER
Thanks for your reply.
Something like this will help?
https://tzamtzis.gr/2017/web-analytics/excel-function-md5-hashing-without-vba/
Something like this will help?
https://tzamtzis.gr/2017/web-analytics/excel-function-md5-hashing-without-vba/
No. MD5 is a hashing algorithm, not an encrypting algorithm. You can not un-hash a value back to its original string.
How strong do you need the encrypted text to be?
How strong do you need the encrypted text to be?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Martin your code does not work. Can you explain ?
Gowflow
Gowflow
I updated the workbook.
I just downloaded and still same code same results !!!
Gowflow
Gowflow
Martin's workbook is working for me in Mac Excel 2016.
Thanks. In case anyone has a problem, this is how to use it.
- Click the Encrypt button
- It will ask you for a phrase which it will use to encrypt (actually hash) C4. The phrase can be anything from "xxx" to" I think Martin is a great programmer" (all without quotes)
- When you want to decrypt, press the Decrypt button and enter the phrase you used previously. It must be EXACTLY the same.
ASKER
Martin I found a bug.
When you click encrypt and click cancel it still encrypts the password.
Is it possible to adjust the VBA codes to cancel the encryption when I click cancel.
When you click encrypt and click cancel it still encrypts the password.
Is it possible to adjust the VBA codes to cancel the encryption when I click cancel.
Sure.
Sub Encrypt()
Dim strPhrase As String
strPhrase = InputBox("Please enter the encryption phrase", "Encrypt Password")
If StrPtr(strPhrase) = 0 Then
Exit Sub
End If
Range("C4") = RndCrypt(Range("C4"), strPhrase)
End Sub
Sub Decrypt()
Dim strPhrase As String
strPhrase = InputBox("Please enter the decryption phrase", "Decrypt Password")
If StrPtr(strPhrase) = 0 Then
Exit Sub
End If
Range("C4") = RndCrypt(Range("C4"), strPhrase)
End Sub
ASKER
One more request
I want to encrypt or decrypt only selected cell.
As of now it is only encrypting and decrypting C4 cell.
I want to encrypt or decrypt only selected cell.
As of now it is only encrypting and decrypting C4 cell.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much Martin
The last code when it comes to a Selection need to be amended as follows:
Gowflow
Sub Decrypt()
Dim strPhrase As String
Dim cCell As Range
strPhrase = InputBox("Please enter the decryption phrase", "Decrypt Password")
If StrPtr(strPhrase) = 0 Then
Exit Sub
End If
For Each cCell In Selection
cCell = RndCrypt(cCell, strPhrase)
Next cCell
End Sub
Sub Decrypt()
Dim strPhrase As String
Dim cCell As Range
strPhrase = InputBox("Please enter the decryption phrase", "Decrypt Password")
If StrPtr(strPhrase) = 0 Then
Exit Sub
End If
For Each cCell In Selection
cCell = RndCrypt(cCell, strPhrase)
Next cCell
End Sub
Gowflow
ASKER
There is a mistake I guess. Your help is appreciated.
If I type wrong phrase by mistake I cannot undo to type the correct phrase and get the correct password.
i.e. I lost the original password. :(
Thank you very much for your time/help.
If I type wrong phrase by mistake I cannot undo to type the correct phrase and get the correct password.
i.e. I lost the original password. :(
Thank you very much for your time/help.
Do you have any kind of backup?
ASKER
No.
:(
But no problem I didn't loose any password which is not recoverable.
But it may happen in future.
:(
But no problem I didn't loose any password which is not recoverable.
But it may happen in future.
You can use a password manager to save your passwords.