Advertisement
2002ASP Encryption #715

encryptAll

This simple encryption Function uses Xor encryption and itterative encoding to more securely encrypt a text string. Although the code is not unbreakable, it cannot be broken with a simple key. Itterative encoding ensures that code-cracking techniques, like character frequency study, will not work. It's as easy as could be. Function can be easily modified to encode more than strings.

AI

AIサマリー: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ソースコード
original-source
Public Function encryptAll(data As String, seed As Long) As String
Dim x As Integer, tmp As String, stepnum As Integer
Dim byteArray() As Byte, seedOffset As Integer, n As String
tmp = Trim$(Str(seed))
seed = 0
For x = 1 To Len(tmp)
n = Mid(tmp, x, 1)
 seed = seed + CLng(n)
Next x
 
reCheckSeed:
 If seed > 255 Then
  seed = -1 + (seed - 255)
  GoTo reCheckSeed
 End If
For x = 1 To Len(data)
 ReDim Preserve byteArray(x)
 n = Mid(data, x, 1)
 byteArray(x) = Asc(n)
 
 stepnum = seed + x
reCheckstepnum:
 If stepnum > 255 Then
  stepnum = -1 + (stepnum - 255)
  GoTo reCheckstepnum
 End If
 
 byteArray(x) = byteArray(x) Xor CByte(stepnum)
 
Next x
 tmp = ""
 For x = 1 To Len(data)
  tmp = tmp & Chr(byteArray(x))
 Next x
encryptAll = tmp
End Function
オリジナルのコメント (3)
Wayback Machineから復元