pissuda , oyage Diary pro eka oyama hadanna oni,koondeGoda said:hey vbmaster
Diary program project file . do it better way
me code mage nemei , but i think these ar good , mage code yata thiyenawa
Below is an encryption class that encrypts both ASCII and Unicode text using a password. An example of how to use the class is given below:
'Demo routine
Sub Test()
Dim oEncrypt As clsEncrypt
Dim sText As String
Dim bIsUnicde As Boolean
Set oEncrypt = New clsEncrypt
bIsUnicde = False
'Set password
oEncrypt.Password = "andrewbakerisace"
sText = "my secret text"
'Encrypt text
Debug.Print "Before encryption: " & sText
sText = oEncrypt.EncryptOrDecrypt(sText, bIsUnicde)
Debug.Print "After encryption: " & sText
'Decrypt text
sText = oEncrypt.EncryptOrDecrypt(sText, bIsUnicde)
Debug.Print "After unencrypting: " & sText
End Sub
ADD TO A CLASS MODULE CALLED "clsEncrypt"
-----------------------------------------
-----------------------------------------
'Copyright 2005 www.vbusers.com
'Encryption class for encrypting and decrypting text using a password and an XOR operator.
'Written by Andrew Baker
'For the Terms and conditions see http://www.vbusers.com/TermsAndConditions.asp
Option Explicit
'---------------Private class variables-----------------
Private zsPassword As String
'Purpose : Gets or sets the password used by the encryption routines
'Inputs : N/A
'Outputs : N/A
'Date : 25/03/2005
'Notes :
Property Get Password() As String
Password = zsPassword
End Property
Property Let Password(value As String)
zsPassword = value
End Property
'Purpose : Encrypts or decrypts the supplied string.
'Inputs : sData The data to process.
' [bUseUnicode] If true, converts unicode text else converts ASCII text.
'Outputs : Returns an encrypted string if the input was unencrypted, or a decrypted string if
' the input was encrypted/
'Date : 25/03/2005
'Notes :
Function EncryptOrDecrypt(sData As String, Optional bUseUnicode As Boolean = False) As String
Dim abData() As Byte, abPassword() As Byte
If Len(sData) > 0 And Len(zsPassword) > 0 Then
If bUseUnicode Then
abData = sData
abPassword = zsPassword
Else
'All VB text is stored in Unicode, so must convert back to ASCII first
abData = StrConv(sData, vbFromUnicode)
abPassword = StrConv(zsPassword, vbFromUnicode)
End If
EncryptOrDecrypt = zEncryptArray(abData, abPassword, bUseUnicode)
Else
'Either no data or password has been set
EncryptOrDecrypt = sData
End If
End Function
'Purpose : Encrypts or decrypts the specified byte array using the password string with an XOR operator.
'Inputs : abData A byte array containing the data to encrypt.
' abPassword The password to encrypt the data with.
'Outputs : Returns the encrypted or decrypted byte array.
'Date : 25/03/2001
'Notes :
Private Function zEncryptArray(abData() As Byte, abPassword() As Byte, bUseUnicode As Boolean) As Byte()
Dim lThisLine As Long
Dim abResults() As Byte
Dim lPasswordIndex As Long
On Error GoTo ErrFailed
'Size the array to store the resulting data
ReDim abResults(LBound(abData) To UBound(abData))
'Loop over each byte in the data array, apply the encryption algorithm
For lThisLine = 0 To UBound(abData)
'Encrypt the byte
abResults(lThisLine) = zEncryptByte(abData(lThisLine), abPassword, lPasswordIndex)
Next
'Return the results
If bUseUnicode Then
'Array will already be in Unicode format
zEncryptArray = abResults
Else
'Have to convert back to Unicode before storing as a string
zEncryptArray = StrConv(abResults, vbUnicode)
End If
Exit Function
ErrFailed:
Debug.Print "Error in zEncryptArray: " & Err.Description
Debug.Assert False
End Function
'Purpose : This function Encrypts one byte, then modifies the password.
'Inputs : bytValue A byte array containing the data to encrypt.
' abPassword The password to encrypt the data with.
'Outputs : Returns the input byte after the encryption algorithm has been applied to it.
'Author : Andrew Baker
'Date : 04/09/2000
'Notes : Modifies the password bytes after each iteration to make decryption harder.
'Revisions :
Private Function zEncryptByte(bytValue As Byte, abPassword() As Byte, lPasswordIndex As Long) As Byte
On Error GoTo ErrFailed
If lPasswordIndex = UBound(abPassword) - 1 Then
'Text exceeded password, reset password array
lPasswordIndex = 0
End If
'Exclusive or the byte with the current password byte
zEncryptByte = bytValue Xor abPassword(lPasswordIndex)
'Exclusive or the byte with the first character of the password
'multiplied by the current index into the password. And the result with
'256 to avoid possible overflow errors
zEncryptByte = (zEncryptByte Xor CInt(abPassword(lPasswordIndex)) * lPasswordIndex) And &HFF
'Modify the password.
'set the current byte in the password to the current byte plus the next byte.
abPassword(lPasswordIndex) = (CInt(abPassword(lPasswordIndex)) + abPassword(lPasswordIndex + 1)) And &HFF
'Increment the password index
lPasswordIndex = lPasswordIndex + 1
Exit Function
ErrFailed:
Debug.Print "Error in zEncryptByte: " & Err.Description
Debug.Assert False
End Function
menna man dena easy code wagayak i use vb6 same 2 .net
Public Function Coding(text As String) As String
If Len(text) < 1 Then Exit Function
Randomize (Time)
Dim LetterNo As Long
Dim TempLetter As Long
Dim ACLNo As Long
For LetterNo = 1 To Len(text)
ACLNo = Asc(Mid(text, LetterNo, 1))
TempLetter = Rnd(23) * 15
ACLNo = ACLNo + TempLetter + 5 ' this is the magic Number mekata 5 th 100 (kamathinam 5 to 1000 dala check karala balanna )atara daganna , anith ayata (me code dakka aytath) behe me no eka danne nathwa encode karanna . + ekata - pavichchi karannath puluwan eth rina ganak awoth err ekak enna puluwan
Coding = Coding & Chr(ACLNo) & Chr(TempLetter)
Next
End Function
Public Function EnCoding(text As String) As String
Dim LetterNo As Long
Dim TempLetter As Long
Dim ACLNo As Long
For LetterNo = 1 To Len(text) Step 2
ACLNo = Asc(Mid(text, LetterNo, 1))
TempLetter = Asc(Mid(text, LetterNo + 1, 1))
ACLNo = ACLNo - TempLetter - 5 'same no, arake - pavichchi kara nam meke + use karanna
EnCoding = EnCoding & Chr(ACLNo)
Next
End Function
"coderef" pavichchi karanne nathuwa reg ekata liyanna
SaveSetting App.Title, "Diary", "paaaword", "user password" ' code password eka or variable eka danna
txtpass.text = GetSetting App.Title, "Diary", "paaaword", "No password" reg valu eka nathnam default eka vidihata Nopassword eka ei
watting ur reply
Last edited:
, mata thama ahasin yanna behene . 





