By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,005 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

Data Encryption/Hijri Dates Conversion

P: n/a
Dear Respected Gurus/Sirs,

I would like to share your ideas and get reviews will be highly
appreciated in anticipation

Question No.1
I had developed a seprate audit/security database that stored
userID,Password,Username to track who has logon/logout, and what
actions had performed(add, edit, delete, update etc). now the question
who to encrypt the data, what mehtodology is best where at least
password should be kept hided...or protected. as this mdb is linked
with other 10 mdb and data comes from there of various kinds so i have
to used also link table, and link table also wants to hide. just
hiding msysobjects is very easy method. can some one has experience or
share ideas on it.
Question No.2
I had found convertion function from net on same group, i success in
conversion from georgian date to hijri date format, without changing
any of my regional setting. now the problem after converting in hirji
date/year shows in arabic and name of months appear in english...this
is strange behvaior happening to me
say the date today is 3/10/2004, so the out put should be 19/8/1425
but system gives 19/aug/1425 that month name is wrong... i am posting
the codes of it also

- This is the fucntion i used in module
Function strHijri(dtWestDate As Date) As String
' returns a date in Hijri format for a given western date
VBA.Calendar = vbCalHijri
strHijri = dtWestDate
VBA.Calendar = vbCalGreg
End Function

- this is the text out put codes on form
Me!txtHijri = strHijri(Me!txtGregorian)

can some one put highlight on formatting issues of arabic months name,
i had follow all others links that was published earlier. but none of
them work with this. even download the hijri.bad module posted

thanks and rgds
shahzad
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> Question No.1
I had developed a seprate audit/security database that stored
userID,Password,Username to track who has logon/logout, and what
actions had performed(add, edit, delete, update etc). now the question
who to encrypt the data, what mehtodology is best where at least
password should be kept hided...or protected. as this mdb is linked
with other 10 mdb and data comes from there of various kinds so i have
to used also link table, and link table also wants to hide. just
hiding msysobjects is very easy method. can some one has experience or
share ideas on it.
Hiding a table with password information is not enough to secure the
information. Anyone can link to or externally query the table and acquire
the data.

For each username in your table, instead of storing the straight password in
the Password field of your table, store the HASH of the password. The
following code demonstrates how to hash a string with calls to the advapi32:
'----------------------<< begin code >>----------------------
Private Declare Function CryptAcquireContext Lib "advapi32.dll" _
Alias "CryptAcquireContextA" ( _
ByRef phProv As Long, _
ByVal pszContainer As String, _
ByVal pszProvider As String, _
ByVal dwProvType As Long, _
ByVal dwFlags As Long) As Long

Private Declare Function CryptReleaseContext Lib "advapi32.dll" ( _
ByVal hProv As Long, _
ByVal dwFlags As Long) As Long

Private Declare Function CryptCreateHash Lib "advapi32.dll" ( _
ByVal hProv As Long, _
ByVal Algid As Long, _
ByVal hKey As Long, _
ByVal dwFlags As Long, _
ByRef phHash As Long) As Long

Private Declare Function CryptDestroyHash Lib "advapi32.dll" ( _
ByVal hHash As Long) As Long

Private Declare Function CryptHashData Lib "advapi32.dll" ( _
ByVal hHash As Long, _
pbData As Any, _
ByVal dwDataLen As Long, _
ByVal dwFlags As Long) As Long

Private Declare Function CryptGetHashParam Lib "advapi32.dll" ( _
ByVal hHash As Long, _
ByVal dwParam As Long, _
pbData As Any, _
pdwDataLen As Long, _
ByVal dwFlags As Long) As Long

Private Const PROV_RSA_FULL = 1

Private Const ALG_CLASS_HASH = 32768

Private Const ALG_TYPE_ANY = 0

Private Const ALG_SID_MD2 = 1
Private Const ALG_SID_MD4 = 2
Private Const ALG_SID_MD5 = 3
Private Const ALG_SID_SHA1 = 4

Enum HashAlgorithm
md2 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD2
md4 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD4
MD5 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD5
SHA1 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_SHA1
End Enum

Private Const HP_HASHVAL = 2
Private Const HP_HASHSIZE = 4

Function HashString( _
ByVal Str As String, _
Optional ByVal Algorithm As HashAlgorithm = MD5) As String
Dim hCtx As Long
Dim hHash As Long
Dim lRes As Long
Dim lLen As Long
Dim lIdx As Long
Dim abData() As Byte

lRes = CryptAcquireContext(hCtx, vbNullString, _
vbNullString, PROV_RSA_FULL, 0)
If lRes <> 0 Then
lRes = CryptCreateHash(hCtx, Algorithm, 0, 0, hHash)
If lRes <> 0 Then
lRes = CryptHashData(hHash, ByVal Str, Len(Str), 0)
If lRes <> 0 Then
lRes = CryptGetHashParam(hHash, HP_HASHSIZE, lLen, 4, 0)
If lRes <> 0 Then
ReDim abData(0 To lLen - 1)
lRes = CryptGetHashParam(hHash, HP_HASHVAL, abData(0), lLen,
0)
If lRes <> 0 Then
HashString = StrConv(abData, vbUnicode)
End If
End If
End If
CryptDestroyHash hHash
End If
End If
CryptReleaseContext hCtx, 0
If lRes = 0 Then Err.Raise Err.LastDllError

End Function
'-----------------------<< end code >>-----------------------

The following sample code shows how one might add a User with a username of
"Superg33k" and a password of "gr0nk!" to a table called "UserInfo" with
fields "UserName" and "Password" (call this function with:
?UserAdd("Superg33k","gr0nk!") ):
'----------------------<< begin code >>----------------------
Function UserAdd(UserName As String, Password As String) As Boolean
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * FROM UserInfo WHERE
UserName='" & UserName & "';")
If rst.RecordCount = 0 Then
rst.AddNew
rst!UserName = UserName
rst!Password = HashString(Password)
rst.Update
UserAdd = True
End If
rst.Close
End Function
'-----------------------<< end code >>-----------------------

The following sample code shows how one might verify a User with a username
of "Superg33k" and a password of "gr0nk!" to a table called "UserInfo" with
fields "UserName" and "Password" (call this function with:
?UserCheck("Superg33k","gr0nk!") ):
'----------------------<< begin code >>----------------------
Function UserCheck(UserName As String, Password As String) As Boolean
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * FROM UserInfo WHERE
UserName='" & UserName & "';")
If rst.RecordCount Then
If rst!Password = HashString(Password) Then UserCheck = True
End If
rst.Close
End Function
'-----------------------<< end code >>-----------------------
Question No.2
I had found convertion function from net on same group, i success in
conversion from georgian date to hijri date format, without changing
any of my regional setting. now the problem after converting in hirji
date/year shows in arabic and name of months appear in english...this
is strange behvaior happening to me
say the date today is 3/10/2004, so the out put should be 19/8/1425
but system gives 19/aug/1425 that month name is wrong... i am posting
the codes of it also

- This is the fucntion i used in module
Function strHijri(dtWestDate As Date) As String
' returns a date in Hijri format for a given western date
VBA.Calendar = vbCalHijri
strHijri = dtWestDate
VBA.Calendar = vbCalGreg
End Function

Try this:
'----------------------<< begin code >>----------------------
Function strHijri(dtWestDate As Date) As String
' returns a date in Hijri format for a given western date
VBA.Calendar = vbCalHijri
strHijri = Day(dtWestDate) & "/" _
& Month(dtWestDate) & "/" _
& Year(dtWestDate)
VBA.Calendar = vbCalGreg
End Function
'-----------------------<< end code >>-----------------------
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.