Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
A simple encryption algorithm which will accept al...
Author:
Philfr
E-mail:
Click to e-mail author
Submitted:
5/21/2002
Version:
VB6
Compatibility:
VB6
Category:
Security
Views:
20426
A simple encryption algorithm which will accept all characters including graphics.
Declarations:
'none
Code:
Function RotateLeft(TheString As String, ByVal nbrPlaces As Byte) As String ' Author: Philfr ' Email: philfrankl@yahoo.com ' Date: 25 - 5 - 02 ' Please acknowledge my authorship by retaining the above 3 lines ' this is a simple encryption algorithm. ' knowing all 'printable' characters are 8 bytes long, ' you can shift the bits to the left and still have a printable character ' to decrypt, all you have to do is to shift them left ' until you have come full circle. ie. ' to Encrypt: RotateLeft(TheString, nbrPlaces) ' to Decrypt: RotateLeft(TheString, 8 - nbrPlaces) Dim tmp As Integer, i As Integer Dim mult As Integer, ln As Integer Dim tmpSt As String ln = Len(TheString) tmpSt = "" nbrPlaces = nbrPlaces Mod 8 ' no point doing more than 7, besides mult = 2 ^ nbrPlaces ' mult (an Integer) would be too small For i = 1 To ln tmp = Asc(Mid$(TheString, i, 1)) ' get ASCII value of each character tmp = tmp * mult ' apply the multiplier tmp = tmp Mod 256 + tmp \ 256 ' rotate any "carry" bit tmpSt = tmpSt & Chr$(tmp) ' add the character to the string Next i RotateLeft = tmpSt End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement