ID: 315

Viewed: 3724

Added: Aug 19, 2002

Version:

Snippet uploaded by: snippet

Written By: Unknown

Demo: Sorry, no demo

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Found on the Net somewhere.....

Simple cryptography

Note: I mean simple. These codes are easily cracked!

Simple cryptography

Note: I mean simple. These codes are easily cracked!

Highlight all by clicking in box

<!---Declaration--->

`'Install a bit of security to your applications. This simple `

'encryption function can serve as both the encoder and

'decoder. In order for this to work properly, you must use

'the same numerical key each time.

'For example,

'

' lets say you have a string, SecretPassword, that is equal

' to 'the toolbox', and you wish to encrypt it.

'

' Call the following:

'

' SecretPassword = Encrypt(SecretPassword, 80)

'

'In this case you are using an encryption key of 80. So,

'the end result would give you a value of '$85p$??<2?(

'. in order to decode it, simply reverse the process, but be

'sure to use the right key!. in real world applications, you

'might want to create keys on the fly using a math algorithm

'and the len statement as a known base, such as:

Dim Key As Integer

Key = (Int(Sqr(Len(SecretPassword) * 95)) + 21)

'For the string SecretPassword = "the toolbox", a key of 53

'would be generated using the algorithm above.

'To get real sneaky, you can play around with this code all you

'want, but this is only a start!

'Here is the magic code to do the encryption. If you'll notice, it is the same encryption code used in the

'screen saver template.

Highlight All

<!---Code--->

Function Encrypt (Text As String, EncryptKey As Integer)

Dim Temp As String, RR As Integer

For RR = 1 To Len(Text)

Temp$ = Temp$ + Chr$(Asc(Mid(Text, RR, 1)) Xor EncryptKey)

Next RR

Encrypt = Temp

End Function'

;

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.