473,382 Members | 1,380 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,382 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 3714
> 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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.