VBA Help Please encrypt data

M

Markus

Hallo

I hope some one can help me im not a good access VB expert i have found this
sample DB that uses AES encrypt but i need to change it a little to do what i
need but i don't know how. I'm sure for a VB expert it should take not more
then a few minutes to change it I will gladly send the person a bottle of win
if you can send me a working sample.

The sample files can be found here
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='AES Encryption.zip'

What i need it encrypt not just one field at a time. I have a table with
calling cards and there pin number so what i want is to tell it take a temp
table encrypt it into a different table but only the pin number column needs
to be encrypted. Now the other thing i need is a different DB i have a query
that reads the encrypted Pins and now i needs to decrypt them into a temp
table so they can be printed.

The encrypt key needs to be part of the code but so that i can change it
If some one could do this for me i would be very grate full. And really i
will post you a nice bottle of German wine to as a token.

Regards

Markus

Ps if you have any question you can email me at (e-mail address removed)
 
K

Klatuu

Here is a function you can use to encrypt one value(field or variable).
The first argument (iToDo) tells the function to encrypt or decrypt the
string passed.
1 = encrypt - 2 = decrypt
The second argument(strPass) is the string you want either encrypted or
decrypted. If you pass it 2 and an encrypted string, it will return the plain
text version. If you pass it 1 and a plain text string, it will return the
string encrypted. Ignore the third argument, you really don't need it.

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function
*************
Now, for using it in a query:
Where you would normally put the field name to retrieve the data from the
table, you need to make it an expression:
Normal for say [MyPinField]
Pin: EncryptCode(2, [MyTableName]![MyPinField]

To put it into the table using a query do the same thing except put it in
the Update To row for the field you want to encrypt:
Pin: EncryptCode(1, StrPinCodeVariable)

I prefer Merlot :)
 
M

Markus

Hi It does not work

I did the folowing i create a new module called EncryptCode and iserted the
following into it

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Created a update query with the temp table called Temp_Pin_number added the
field thats needs updating called Pin_Number with the update to Pin:
EncryptCode(1, StrPinCodeVariable) when save it i get the error

The expression you entered has an invalid . (dot) or ! operator or invalid
parentheses.
You may have entered an invalid identifier or typed parentheses following
the Null constant.

Could you tell me what i did wrong.

Why does it have to be a update query should it not be a append query since
i want to encrypte it from the temp table into the correct table or do i have
to do a update first and then append it to the main pin table.

Regards
Markus

Klatuu said:
Here is a function you can use to encrypt one value(field or variable).
The first argument (iToDo) tells the function to encrypt or decrypt the
string passed.
1 = encrypt - 2 = decrypt
The second argument(strPass) is the string you want either encrypted or
decrypted. If you pass it 2 and an encrypted string, it will return the plain
text version. If you pass it 1 and a plain text string, it will return the
string encrypted. Ignore the third argument, you really don't need it.

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function
*************
Now, for using it in a query:
Where you would normally put the field name to retrieve the data from the
table, you need to make it an expression:
Normal for say [MyPinField]
Pin: EncryptCode(2, [MyTableName]![MyPinField]

To put it into the table using a query do the same thing except put it in
the Update To row for the field you want to encrypt:
Pin: EncryptCode(1, StrPinCodeVariable)

I prefer Merlot :)
Markus said:
Hallo

I hope some one can help me im not a good access VB expert i have found this
sample DB that uses AES encrypt but i need to change it a little to do what i
need but i don't know how. I'm sure for a VB expert it should take not more
then a few minutes to change it I will gladly send the person a bottle of win
if you can send me a working sample.

The sample files can be found here
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='AES Encryption.zip'

What i need it encrypt not just one field at a time. I have a table with
calling cards and there pin number so what i want is to tell it take a temp
table encrypt it into a different table but only the pin number column needs
to be encrypted. Now the other thing i need is a different DB i have a query
that reads the encrypted Pins and now i needs to decrypt them into a temp
table so they can be printed.

The encrypt key needs to be part of the code but so that i can change it
If some one could do this for me i would be very grate full. And really i
will post you a nice bottle of German wine to as a token.

Regards

Markus

Ps if you have any question you can email me at (e-mail address removed)
 
K

Klatuu

I don't see anything wrong with the code. I know it works, I have been using
it for about 5 or 6 years, starting in Access 97. The only thing I see is
you have this in 2 times:
EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Was that an error in the post, or is it in your module? Also, I don't know
what effect it has, but it is my understanding you should not name a module
and a procedure the same name.
It does not have to be an update query, the same holds true for an append
query.

Have you tried running it from the immediate window to see what results you
get there. Perhaps it is a problem with the syntax in the query.

Markus said:
Hi It does not work

I did the folowing i create a new module called EncryptCode and iserted the
following into it

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Created a update query with the temp table called Temp_Pin_number added the
field thats needs updating called Pin_Number with the update to Pin:
EncryptCode(1, StrPinCodeVariable) when save it i get the error

The expression you entered has an invalid . (dot) or ! operator or invalid
parentheses.
You may have entered an invalid identifier or typed parentheses following
the Null constant.

Could you tell me what i did wrong.

Why does it have to be a update query should it not be a append query since
i want to encrypte it from the temp table into the correct table or do i have
to do a update first and then append it to the main pin table.

Regards
Markus

Klatuu said:
Here is a function you can use to encrypt one value(field or variable).
The first argument (iToDo) tells the function to encrypt or decrypt the
string passed.
1 = encrypt - 2 = decrypt
The second argument(strPass) is the string you want either encrypted or
decrypted. If you pass it 2 and an encrypted string, it will return the plain
text version. If you pass it 1 and a plain text string, it will return the
string encrypted. Ignore the third argument, you really don't need it.

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function
*************
Now, for using it in a query:
Where you would normally put the field name to retrieve the data from the
table, you need to make it an expression:
Normal for say [MyPinField]
Pin: EncryptCode(2, [MyTableName]![MyPinField]

To put it into the table using a query do the same thing except put it in
the Update To row for the field you want to encrypt:
Pin: EncryptCode(1, StrPinCodeVariable)

I prefer Merlot :)
Markus said:
Hallo

I hope some one can help me im not a good access VB expert i have found this
sample DB that uses AES encrypt but i need to change it a little to do what i
need but i don't know how. I'm sure for a VB expert it should take not more
then a few minutes to change it I will gladly send the person a bottle of win
if you can send me a working sample.

The sample files can be found here
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='AES Encryption.zip'

What i need it encrypt not just one field at a time. I have a table with
calling cards and there pin number so what i want is to tell it take a temp
table encrypt it into a different table but only the pin number column needs
to be encrypted. Now the other thing i need is a different DB i have a query
that reads the encrypted Pins and now i needs to decrypt them into a temp
table so they can be printed.

The encrypt key needs to be part of the code but so that i can change it
If some one could do this for me i would be very grate full. And really i
will post you a nice bottle of German wine to as a token.

Regards

Markus

Ps if you have any question you can email me at (e-mail address removed)
 
M

Markus

Sorry that was only a mistake in the post

Ok i have rename the module to module

and i still have the same error when runing the query and when i click ok ok
it highlight the (

This is the SQL view of the code

And when i try to decrypte i get the error enter paramter value. But that
maybe because i did not encrypt it yet

Could you maybe make a little sample data base and email to me where is
perfectly workin on your side




I

Klatuu said:
I don't see anything wrong with the code. I know it works, I have been using
it for about 5 or 6 years, starting in Access 97. The only thing I see is
you have this in 2 times:
EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Was that an error in the post, or is it in your module? Also, I don't know
what effect it has, but it is my understanding you should not name a module
and a procedure the same name.
It does not have to be an update query, the same holds true for an append
query.

Have you tried running it from the immediate window to see what results you
get there. Perhaps it is a problem with the syntax in the query.

Markus said:
Hi It does not work

I did the folowing i create a new module called EncryptCode and iserted the
following into it

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Created a update query with the temp table called Temp_Pin_number added the
field thats needs updating called Pin_Number with the update to Pin:
EncryptCode(1, StrPinCodeVariable) when save it i get the error

The expression you entered has an invalid . (dot) or ! operator or invalid
parentheses.
You may have entered an invalid identifier or typed parentheses following
the Null constant.

Could you tell me what i did wrong.

Why does it have to be a update query should it not be a append query since
i want to encrypte it from the temp table into the correct table or do i have
to do a update first and then append it to the main pin table.

Regards
Markus

Klatuu said:
Here is a function you can use to encrypt one value(field or variable).
The first argument (iToDo) tells the function to encrypt or decrypt the
string passed.
1 = encrypt - 2 = decrypt
The second argument(strPass) is the string you want either encrypted or
decrypted. If you pass it 2 and an encrypted string, it will return the plain
text version. If you pass it 1 and a plain text string, it will return the
string encrypted. Ignore the third argument, you really don't need it.

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function
*************
Now, for using it in a query:
Where you would normally put the field name to retrieve the data from the
table, you need to make it an expression:
Normal for say [MyPinField]
Pin: EncryptCode(2, [MyTableName]![MyPinField]

To put it into the table using a query do the same thing except put it in
the Update To row for the field you want to encrypt:
Pin: EncryptCode(1, StrPinCodeVariable)

I prefer Merlot :)
:

Hallo

I hope some one can help me im not a good access VB expert i have found this
sample DB that uses AES encrypt but i need to change it a little to do what i
need but i don't know how. I'm sure for a VB expert it should take not more
then a few minutes to change it I will gladly send the person a bottle of win
if you can send me a working sample.

The sample files can be found here
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='AES Encryption.zip'

What i need it encrypt not just one field at a time. I have a table with
calling cards and there pin number so what i want is to tell it take a temp
table encrypt it into a different table but only the pin number column needs
to be encrypted. Now the other thing i need is a different DB i have a query
that reads the encrypted Pins and now i needs to decrypt them into a temp
table so they can be printed.

The encrypt key needs to be part of the code but so that i can change it
If some one could do this for me i would be very grate full. And really i
will post you a nice bottle of German wine to as a token.

Regards

Markus

Ps if you have any question you can email me at (e-mail address removed)
 
K

Klatuu

Please post back exactly the syntax you are using to call it.
Also, Please don't use name of Access objects like Module. Try something
like:
basEncryption or modEncrypt. Either follows good naming conventions.
The only database I have that uses it is very large and contains sensitive
data. I'll see if I can send an example.

Markus said:
Sorry that was only a mistake in the post

Ok i have rename the module to module

and i still have the same error when runing the query and when i click ok ok
it highlight the (

This is the SQL view of the code

And when i try to decrypte i get the error enter paramter value. But that
maybe because i did not encrypt it yet

Could you maybe make a little sample data base and email to me where is
perfectly workin on your side




I

Klatuu said:
I don't see anything wrong with the code. I know it works, I have been using
it for about 5 or 6 years, starting in Access 97. The only thing I see is
you have this in 2 times:
EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Was that an error in the post, or is it in your module? Also, I don't know
what effect it has, but it is my understanding you should not name a module
and a procedure the same name.
It does not have to be an update query, the same holds true for an append
query.

Have you tried running it from the immediate window to see what results you
get there. Perhaps it is a problem with the syntax in the query.

Markus said:
Hi It does not work

I did the folowing i create a new module called EncryptCode and iserted the
following into it

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Created a update query with the temp table called Temp_Pin_number added the
field thats needs updating called Pin_Number with the update to Pin:
EncryptCode(1, StrPinCodeVariable) when save it i get the error

The expression you entered has an invalid . (dot) or ! operator or invalid
parentheses.
You may have entered an invalid identifier or typed parentheses following
the Null constant.

Could you tell me what i did wrong.

Why does it have to be a update query should it not be a append query since
i want to encrypte it from the temp table into the correct table or do i have
to do a update first and then append it to the main pin table.

Regards
Markus

:

Here is a function you can use to encrypt one value(field or variable).
The first argument (iToDo) tells the function to encrypt or decrypt the
string passed.
1 = encrypt - 2 = decrypt
The second argument(strPass) is the string you want either encrypted or
decrypted. If you pass it 2 and an encrypted string, it will return the plain
text version. If you pass it 1 and a plain text string, it will return the
string encrypted. Ignore the third argument, you really don't need it.

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function
*************
Now, for using it in a query:
Where you would normally put the field name to retrieve the data from the
table, you need to make it an expression:
Normal for say [MyPinField]
Pin: EncryptCode(2, [MyTableName]![MyPinField]

To put it into the table using a query do the same thing except put it in
the Update To row for the field you want to encrypt:
Pin: EncryptCode(1, StrPinCodeVariable)

I prefer Merlot :)
:

Hallo

I hope some one can help me im not a good access VB expert i have found this
sample DB that uses AES encrypt but i need to change it a little to do what i
need but i don't know how. I'm sure for a VB expert it should take not more
then a few minutes to change it I will gladly send the person a bottle of win
if you can send me a working sample.

The sample files can be found here
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='AES Encryption.zip'

What i need it encrypt not just one field at a time. I have a table with
calling cards and there pin number so what i want is to tell it take a temp
table encrypt it into a different table but only the pin number column needs
to be encrypted. Now the other thing i need is a different DB i have a query
that reads the encrypted Pins and now i needs to decrypt them into a temp
table so they can be printed.

The encrypt key needs to be part of the code but so that i can change it
If some one could do this for me i would be very grate full. And really i
will post you a nice bottle of German wine to as a token.

Regards

Markus

Ps if you have any question you can email me at (e-mail address removed)
 
K

Klatuu

I just emailed a picture of where it is used in a query. This is a select
query as it is not used in an update or append query in this application.

Markus said:
Sorry that was only a mistake in the post

Ok i have rename the module to module

and i still have the same error when runing the query and when i click ok ok
it highlight the (

This is the SQL view of the code

And when i try to decrypte i get the error enter paramter value. But that
maybe because i did not encrypt it yet

Could you maybe make a little sample data base and email to me where is
perfectly workin on your side




I

Klatuu said:
I don't see anything wrong with the code. I know it works, I have been using
it for about 5 or 6 years, starting in Access 97. The only thing I see is
you have this in 2 times:
EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Was that an error in the post, or is it in your module? Also, I don't know
what effect it has, but it is my understanding you should not name a module
and a procedure the same name.
It does not have to be an update query, the same holds true for an append
query.

Have you tried running it from the immediate window to see what results you
get there. Perhaps it is a problem with the syntax in the query.

Markus said:
Hi It does not work

I did the folowing i create a new module called EncryptCode and iserted the
following into it

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Created a update query with the temp table called Temp_Pin_number added the
field thats needs updating called Pin_Number with the update to Pin:
EncryptCode(1, StrPinCodeVariable) when save it i get the error

The expression you entered has an invalid . (dot) or ! operator or invalid
parentheses.
You may have entered an invalid identifier or typed parentheses following
the Null constant.

Could you tell me what i did wrong.

Why does it have to be a update query should it not be a append query since
i want to encrypte it from the temp table into the correct table or do i have
to do a update first and then append it to the main pin table.

Regards
Markus

:

Here is a function you can use to encrypt one value(field or variable).
The first argument (iToDo) tells the function to encrypt or decrypt the
string passed.
1 = encrypt - 2 = decrypt
The second argument(strPass) is the string you want either encrypted or
decrypted. If you pass it 2 and an encrypted string, it will return the plain
text version. If you pass it 1 and a plain text string, it will return the
string encrypted. Ignore the third argument, you really don't need it.

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function
*************
Now, for using it in a query:
Where you would normally put the field name to retrieve the data from the
table, you need to make it an expression:
Normal for say [MyPinField]
Pin: EncryptCode(2, [MyTableName]![MyPinField]

To put it into the table using a query do the same thing except put it in
the Update To row for the field you want to encrypt:
Pin: EncryptCode(1, StrPinCodeVariable)

I prefer Merlot :)
:

Hallo

I hope some one can help me im not a good access VB expert i have found this
sample DB that uses AES encrypt but i need to change it a little to do what i
need but i don't know how. I'm sure for a VB expert it should take not more
then a few minutes to change it I will gladly send the person a bottle of win
if you can send me a working sample.

The sample files can be found here
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='AES Encryption.zip'

What i need it encrypt not just one field at a time. I have a table with
calling cards and there pin number so what i want is to tell it take a temp
table encrypt it into a different table but only the pin number column needs
to be encrypted. Now the other thing i need is a different DB i have a query
that reads the encrypted Pins and now i needs to decrypt them into a temp
table so they can be printed.

The encrypt key needs to be part of the code but so that i can change it
If some one could do this for me i would be very grate full. And really i
will post you a nice bottle of German wine to as a token.

Regards

Markus

Ps if you have any question you can email me at (e-mail address removed)
 
M

Markus

OK changed it to modEncrypt
I have mad Jpeg pictures of the error i receive you can get them from my
yahoo briefcase

http://uk.f1.pg.briefcase.yahoo.com/bc/mmortsiefer/lst?&.dir=/My+Documents&.src=bc&.view=l

The sample database would really be a greate help maybe you can find my
mistake in the pics i send

Markus

Klatuu said:
Please post back exactly the syntax you are using to call it.
Also, Please don't use name of Access objects like Module. Try something
like:
basEncryption or modEncrypt. Either follows good naming conventions.
The only database I have that uses it is very large and contains sensitive
data. I'll see if I can send an example.

Markus said:
Sorry that was only a mistake in the post

Ok i have rename the module to module

and i still have the same error when runing the query and when i click ok ok
it highlight the (

This is the SQL view of the code

And when i try to decrypte i get the error enter paramter value. But that
maybe because i did not encrypt it yet

Could you maybe make a little sample data base and email to me where is
perfectly workin on your side




I

Klatuu said:
I don't see anything wrong with the code. I know it works, I have been using
it for about 5 or 6 years, starting in Access 97. The only thing I see is
you have this in 2 times:
EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Was that an error in the post, or is it in your module? Also, I don't know
what effect it has, but it is my understanding you should not name a module
and a procedure the same name.
It does not have to be an update query, the same holds true for an append
query.

Have you tried running it from the immediate window to see what results you
get there. Perhaps it is a problem with the syntax in the query.

:

Hi It does not work

I did the folowing i create a new module called EncryptCode and iserted the
following into it

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Created a update query with the temp table called Temp_Pin_number added the
field thats needs updating called Pin_Number with the update to Pin:
EncryptCode(1, StrPinCodeVariable) when save it i get the error

The expression you entered has an invalid . (dot) or ! operator or invalid
parentheses.
You may have entered an invalid identifier or typed parentheses following
the Null constant.

Could you tell me what i did wrong.

Why does it have to be a update query should it not be a append query since
i want to encrypte it from the temp table into the correct table or do i have
to do a update first and then append it to the main pin table.

Regards
Markus

:

Here is a function you can use to encrypt one value(field or variable).
The first argument (iToDo) tells the function to encrypt or decrypt the
string passed.
1 = encrypt - 2 = decrypt
The second argument(strPass) is the string you want either encrypted or
decrypted. If you pass it 2 and an encrypted string, it will return the plain
text version. If you pass it 1 and a plain text string, it will return the
string encrypted. Ignore the third argument, you really don't need it.

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function
*************
Now, for using it in a query:
Where you would normally put the field name to retrieve the data from the
table, you need to make it an expression:
Normal for say [MyPinField]
Pin: EncryptCode(2, [MyTableName]![MyPinField]

To put it into the table using a query do the same thing except put it in
the Update To row for the field you want to encrypt:
Pin: EncryptCode(1, StrPinCodeVariable)

I prefer Merlot :)
:

Hallo

I hope some one can help me im not a good access VB expert i have found this
sample DB that uses AES encrypt but i need to change it a little to do what i
need but i don't know how. I'm sure for a VB expert it should take not more
then a few minutes to change it I will gladly send the person a bottle of win
if you can send me a working sample.

The sample files can be found here
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='AES Encryption.zip'

What i need it encrypt not just one field at a time. I have a table with
calling cards and there pin number so what i want is to tell it take a temp
table encrypt it into a different table but only the pin number column needs
to be encrypted. Now the other thing i need is a different DB i have a query
that reads the encrypted Pins and now i needs to decrypt them into a temp
table so they can be printed.

The encrypt key needs to be part of the code but so that i can change it
If some one could do this for me i would be very grate full. And really i
will post you a nice bottle of German wine to as a token.

Regards

Markus

Ps if you have any question you can email me at (e-mail address removed)
 
K

Klatuu

First problem:
Pin: EncryptCode(2; Temp_Pin_Number!Pin_number)
You have ; where , should be after the two.
Is Temp_Pin_Number another table or query? I think what you meant was
Temp_Pin_Table
It is best to bracket table and field names in queries:
[Temp_Pin_Table]![Pin_Number]
This would be correct in any case; however, when there is only one table or
query involved, it is not necessary to include the Table/Query name so this
should work:
EncryptCode(2, [Pin_number])

The code appears to be correct. Again, try running the code from the
immediate window to see if you get the expected results. First, take a
string and encrypt it to a varialbe, then use the varialbe to decrypt and the
results should be the same as when you encrypted it. Once you know the
function is functioning :) do the queries.

Next:
What is in strPinCodeVariable? it should contain the value you want to
encode. also, take out the Pin: That is not correct. It should be correct
as written without the Pin:
Markus said:
OK changed it to modEncrypt
I have mad Jpeg pictures of the error i receive you can get them from my
yahoo briefcase

http://uk.f1.pg.briefcase.yahoo.com/bc/mmortsiefer/lst?&.dir=/My+Documents&.src=bc&.view=l

The sample database would really be a greate help maybe you can find my
mistake in the pics i send

Markus

Klatuu said:
Please post back exactly the syntax you are using to call it.
Also, Please don't use name of Access objects like Module. Try something
like:
basEncryption or modEncrypt. Either follows good naming conventions.
The only database I have that uses it is very large and contains sensitive
data. I'll see if I can send an example.

Markus said:
Sorry that was only a mistake in the post

Ok i have rename the module to module

and i still have the same error when runing the query and when i click ok ok
it highlight the (

This is the SQL view of the code

And when i try to decrypte i get the error enter paramter value. But that
maybe because i did not encrypt it yet

Could you maybe make a little sample data base and email to me where is
perfectly workin on your side




I

:

I don't see anything wrong with the code. I know it works, I have been using
it for about 5 or 6 years, starting in Access 97. The only thing I see is
you have this in 2 times:
EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Was that an error in the post, or is it in your module? Also, I don't know
what effect it has, but it is my understanding you should not name a module
and a procedure the same name.
It does not have to be an update query, the same holds true for an append
query.

Have you tried running it from the immediate window to see what results you
get there. Perhaps it is a problem with the syntax in the query.

:

Hi It does not work

I did the folowing i create a new module called EncryptCode and iserted the
following into it

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Created a update query with the temp table called Temp_Pin_number added the
field thats needs updating called Pin_Number with the update to Pin:
EncryptCode(1, StrPinCodeVariable) when save it i get the error

The expression you entered has an invalid . (dot) or ! operator or invalid
parentheses.
You may have entered an invalid identifier or typed parentheses following
the Null constant.

Could you tell me what i did wrong.

Why does it have to be a update query should it not be a append query since
i want to encrypte it from the temp table into the correct table or do i have
to do a update first and then append it to the main pin table.

Regards
Markus

:

Here is a function you can use to encrypt one value(field or variable).
The first argument (iToDo) tells the function to encrypt or decrypt the
string passed.
1 = encrypt - 2 = decrypt
The second argument(strPass) is the string you want either encrypted or
decrypted. If you pass it 2 and an encrypted string, it will return the plain
text version. If you pass it 1 and a plain text string, it will return the
string encrypted. Ignore the third argument, you really don't need it.

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function
*************
Now, for using it in a query:
Where you would normally put the field name to retrieve the data from the
table, you need to make it an expression:
Normal for say [MyPinField]
Pin: EncryptCode(2, [MyTableName]![MyPinField]

To put it into the table using a query do the same thing except put it in
the Update To row for the field you want to encrypt:
Pin: EncryptCode(1, StrPinCodeVariable)

I prefer Merlot :)
:

Hallo

I hope some one can help me im not a good access VB expert i have found this
sample DB that uses AES encrypt but i need to change it a little to do what i
need but i don't know how. I'm sure for a VB expert it should take not more
then a few minutes to change it I will gladly send the person a bottle of win
if you can send me a working sample.

The sample files can be found here
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='AES Encryption.zip'

What i need it encrypt not just one field at a time. I have a table with
calling cards and there pin number so what i want is to tell it take a temp
table encrypt it into a different table but only the pin number column needs
to be encrypted. Now the other thing i need is a different DB i have a query
that reads the encrypted Pins and now i needs to decrypt them into a temp
table so they can be printed.

The encrypt key needs to be part of the code but so that i can change it
If some one could do this for me i would be very grate full. And really i
will post you a nice bottle of German wine to as a token.

Regards

Markus

Ps if you have any question you can email me at (e-mail address removed)
 
M

Markus

I did both as a select query and its working perfectly thank you very much.

Where do you want the bottel of win send to

Klatuu said:
I just emailed a picture of where it is used in a query. This is a select
query as it is not used in an update or append query in this application.

Markus said:
Sorry that was only a mistake in the post

Ok i have rename the module to module

and i still have the same error when runing the query and when i click ok ok
it highlight the (

This is the SQL view of the code

And when i try to decrypte i get the error enter paramter value. But that
maybe because i did not encrypt it yet

Could you maybe make a little sample data base and email to me where is
perfectly workin on your side




I

Klatuu said:
I don't see anything wrong with the code. I know it works, I have been using
it for about 5 or 6 years, starting in Access 97. The only thing I see is
you have this in 2 times:
EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Was that an error in the post, or is it in your module? Also, I don't know
what effect it has, but it is my understanding you should not name a module
and a procedure the same name.
It does not have to be an update query, the same holds true for an append
query.

Have you tried running it from the immediate window to see what results you
get there. Perhaps it is a problem with the syntax in the query.

:

Hi It does not work

I did the folowing i create a new module called EncryptCode and iserted the
following into it

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Created a update query with the temp table called Temp_Pin_number added the
field thats needs updating called Pin_Number with the update to Pin:
EncryptCode(1, StrPinCodeVariable) when save it i get the error

The expression you entered has an invalid . (dot) or ! operator or invalid
parentheses.
You may have entered an invalid identifier or typed parentheses following
the Null constant.

Could you tell me what i did wrong.

Why does it have to be a update query should it not be a append query since
i want to encrypte it from the temp table into the correct table or do i have
to do a update first and then append it to the main pin table.

Regards
Markus

:

Here is a function you can use to encrypt one value(field or variable).
The first argument (iToDo) tells the function to encrypt or decrypt the
string passed.
1 = encrypt - 2 = decrypt
The second argument(strPass) is the string you want either encrypted or
decrypted. If you pass it 2 and an encrypted string, it will return the plain
text version. If you pass it 1 and a plain text string, it will return the
string encrypted. Ignore the third argument, you really don't need it.

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function
*************
Now, for using it in a query:
Where you would normally put the field name to retrieve the data from the
table, you need to make it an expression:
Normal for say [MyPinField]
Pin: EncryptCode(2, [MyTableName]![MyPinField]

To put it into the table using a query do the same thing except put it in
the Update To row for the field you want to encrypt:
Pin: EncryptCode(1, StrPinCodeVariable)

I prefer Merlot :)
:

Hallo

I hope some one can help me im not a good access VB expert i have found this
sample DB that uses AES encrypt but i need to change it a little to do what i
need but i don't know how. I'm sure for a VB expert it should take not more
then a few minutes to change it I will gladly send the person a bottle of win
if you can send me a working sample.

The sample files can be found here
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='AES Encryption.zip'

What i need it encrypt not just one field at a time. I have a table with
calling cards and there pin number so what i want is to tell it take a temp
table encrypt it into a different table but only the pin number column needs
to be encrypted. Now the other thing i need is a different DB i have a query
that reads the encrypted Pins and now i needs to decrypt them into a temp
table so they can be printed.

The encrypt key needs to be part of the code but so that i can change it
If some one could do this for me i would be very grate full. And really i
will post you a nice bottle of German wine to as a token.

Regards

Markus

Ps if you have any question you can email me at (e-mail address removed)
 
K

Klatuu

I don't think you can send wine internationally. Tell you what, take the
price of a bottle of wine and donate it to some charity that is helping the
victims of the Hurricane in Louisanna and Mississippi.

Have a great day!

Markus said:
I did both as a select query and its working perfectly thank you very much.

Where do you want the bottel of win send to

Klatuu said:
I just emailed a picture of where it is used in a query. This is a select
query as it is not used in an update or append query in this application.

Markus said:
Sorry that was only a mistake in the post

Ok i have rename the module to module

and i still have the same error when runing the query and when i click ok ok
it highlight the (

This is the SQL view of the code

And when i try to decrypte i get the error enter paramter value. But that
maybe because i did not encrypt it yet

Could you maybe make a little sample data base and email to me where is
perfectly workin on your side




I

:

I don't see anything wrong with the code. I know it works, I have been using
it for about 5 or 6 years, starting in Access 97. The only thing I see is
you have this in 2 times:
EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Was that an error in the post, or is it in your module? Also, I don't know
what effect it has, but it is my understanding you should not name a module
and a procedure the same name.
It does not have to be an update query, the same holds true for an append
query.

Have you tried running it from the immediate window to see what results you
get there. Perhaps it is a problem with the syntax in the query.

:

Hi It does not work

I did the folowing i create a new module called EncryptCode and iserted the
following into it

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function

EncryptCode = strValue

End Function

Created a update query with the temp table called Temp_Pin_number added the
field thats needs updating called Pin_Number with the update to Pin:
EncryptCode(1, StrPinCodeVariable) when save it i get the error

The expression you entered has an invalid . (dot) or ! operator or invalid
parentheses.
You may have entered an invalid identifier or typed parentheses following
the Null constant.

Could you tell me what i did wrong.

Why does it have to be a update query should it not be a append query since
i want to encrypte it from the temp table into the correct table or do i have
to do a update first and then append it to the main pin table.

Regards
Markus

:

Here is a function you can use to encrypt one value(field or variable).
The first argument (iToDo) tells the function to encrypt or decrypt the
string passed.
1 = encrypt - 2 = decrypt
The second argument(strPass) is the string you want either encrypted or
decrypted. If you pass it 2 and an encrypted string, it will return the plain
text version. If you pass it 1 and a plain text string, it will return the
string encrypted. Ignore the third argument, you really don't need it.

Public Function EncryptCode(iToDo As Integer, strPass As String, _
Optional iSeed As Integer) As String
Dim strValue As String
Dim lngMxx As Long
Dim lngPlace As Long

iSeed = IIf(iSeed = 0, 105, iSeed + 95)

For lngMxx = 1 To Len(strPass)
If iToDo = 1 Then
' encode
lngPlace = (Asc(Mid(strPass, lngMxx, 1)) + 2550 + iSeed - lngMxx)
Mod 255
Else
' decode
lngPlace = 255 - (Abs((Asc(Mid(strPass, lngMxx, 1)) - 2550 -
iSeed + lngMxx) Mod 255))
End If
strValue = strValue + Chr(lngPlace)
Next

EncryptCode = strValue

End Function
*************
Now, for using it in a query:
Where you would normally put the field name to retrieve the data from the
table, you need to make it an expression:
Normal for say [MyPinField]
Pin: EncryptCode(2, [MyTableName]![MyPinField]

To put it into the table using a query do the same thing except put it in
the Update To row for the field you want to encrypt:
Pin: EncryptCode(1, StrPinCodeVariable)

I prefer Merlot :)
:

Hallo

I hope some one can help me im not a good access VB expert i have found this
sample DB that uses AES encrypt but i need to change it a little to do what i
need but i don't know how. I'm sure for a VB expert it should take not more
then a few minutes to change it I will gladly send the person a bottle of win
if you can send me a working sample.

The sample files can be found here
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='AES Encryption.zip'

What i need it encrypt not just one field at a time. I have a table with
calling cards and there pin number so what i want is to tell it take a temp
table encrypt it into a different table but only the pin number column needs
to be encrypted. Now the other thing i need is a different DB i have a query
that reads the encrypted Pins and now i needs to decrypt them into a temp
table so they can be printed.

The encrypt key needs to be part of the code but so that i can change it
If some one could do this for me i would be very grate full. And really i
will post you a nice bottle of German wine to as a token.

Regards

Markus

Ps if you have any question you can email me at (e-mail address removed)
 

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