scramble / unscramble text

B

Bob Howard

Hi...

I have a need to save some text record in a file external to Access. I
write them out, and read them back in again from different forms in my
Access application.

One of the records contains a password (nothing to do with Access --- it's
the user's SMTP password for the email system).

On the form, I capture the password using a field with a password input
mask --- so it's not readable on the form.

But after I write it out, it's then readable by someone simply using
Notepad.

IS there a little kernel of code I can use to scamble the password before I
write it out, and then another piece to unscramble it when I read it back in
again. Basically --- I want it scrambled on the text file.

This is A2K3 / VBA

thanks...

bob h.
 
P

Piet Linden

Hi...

I have a need to save some text record in a file external to Access.  I
write them out, and read them back in again from different forms in my
Access application.

One of the records contains a password (nothing to do with Access --- it's
the user's SMTP password for the email system).

On the form, I capture the password using a field with a password input
mask --- so it's not readable on the form.

But after I write it out, it's then readable by someone simply using
Notepad.

IS there a little kernel of code I can use to scamble the password beforeI
write it out, and then another piece to unscramble it when I read it backin
again.  Basically --- I want it scrambled on the text file.

This is A2K3 / VBA

thanks...

bob h.

I would check out VBNet and look for a crypto algorithm.
simple one:
http://vbnet.mvps.org/code/algorithms/rot39.htm
 
S

Stuart McCall

Bob Howard said:
Hi...

I have a need to save some text record in a file external to Access. I
write them out, and read them back in again from different forms in my
Access application.

One of the records contains a password (nothing to do with Access --- it's
the user's SMTP password for the email system).

On the form, I capture the password using a field with a password input
mask --- so it's not readable on the form.

But after I write it out, it's then readable by someone simply using
Notepad.

IS there a little kernel of code I can use to scamble the password before
I write it out, and then another piece to unscramble it when I read it
back in again. Basically --- I want it scrambled on the text file.

This is A2K3 / VBA

thanks...

bob h.

If you want to keep out casual users, this little function should do the
trick.

Public Function Scramble(ByVal txt$)
If txt = "" Then Exit Function
For n& = 1 To Len(txt)
t = t & Chr$(Asc(Mid$(txt, n, 1)) Xor &HE9)
Next
Scramble = t
End Function

Usage:


Debug.Print Scramble("Stuart")
Result: ºœˆ›

Debug.Print Scramble("ºœˆ›")
Result: Stuart
 
B

Bob Howard

Hi...

I have a need to save some text record in a file external to Access. I
write them out, and read them back in again from different forms in my
Access application.

One of the records contains a password (nothing to do with Access --- it's
the user's SMTP password for the email system).

On the form, I capture the password using a field with a password input
mask --- so it's not readable on the form.

But after I write it out, it's then readable by someone simply using
Notepad.

IS there a little kernel of code I can use to scamble the password before
I
write it out, and then another piece to unscramble it when I read it back
in
again. Basically --- I want it scrambled on the text file.

This is A2K3 / VBA

thanks...

bob h.

I would check out VBNet and look for a crypto algorithm.
simple one:
http://vbnet.mvps.org/code/algorithms/rot39.htm

Piet...

This worked after adding something to check for an empty string... (this was
originally VB code, and that may not have been an issue in VB).

Thanks!

bob h
 
K

Klatuu

It obviously was written for VB.
In Access, you need to remove the .Text property from the control references.
In Access, the .Text property only has a value when the control has the focus.
The Access .Value property is more (but not exactly) like the .Text property
in VB.
 
B

Bob Howard

I had already done that and got it working before I replied (previously).
Basically, it's working just fine and is in place in the application. In
addition to the change you note, the ReDim also failed if an empty string
was passed (it failed with error 7 --- out of memory). So Ihad to fix that
as well. Thanks. Bob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top