473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Data Encryption/Hijri Dates Conversion

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
1 3717
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Colin Steadman | last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very simple tasks anyway), and I'm in a bit of a predicament. I've used a javascript table sorting script from here: ...
5
by: SalimShahzad | last post by:
Dear Respected Gurus, I need a coding assistant converting from gregorian to hijri and vice versa. I have problem with this codes. the problem Gregorian to Hijri gives 100% results. when i enter...
2
by: Ryan Adler | last post by:
I have a terrible headache from this problem. Perhaps someone can help. My XML is formatted like this: <events> <event> <starts-at>123456<starts-at/> <event> ... <events/>
0
by: Hannibal111111 | last post by:
I found this code on a site for doing string encryption/decryption. The string will encrypt fine, but I get this error when I try to decrypt. Any idea why? I posted the code below. The error...
6
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
9
by: Busbait | last post by:
I have a problem with Insert into SQL statement. When I use the below SQL to insert a Hijri date , the date will be stored in the table as Gregorian date. How can I specify the date that I am...
8
by: ArbolOne | last post by:
Hello every one, just wanted to know if anyone here has, or knows where to get, code or the algorithm for the Hijri Calendar. Thanks
13
by: Tom Andrecht | last post by:
I'm trying to get some encryption/decryption routines going to take care of my data, and while the encryption is working great, I keep running into the message "Padding is invalid and cannot be...
6
by: Mike Copeland | last post by:
I am working with a file of data that contains "time values" (e.g. "1225365563"), and I want to convert this data into something I can use in a program I'm developing. From what I've read about...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.