I found here:
http://social.technet.microsoft.com/For ... n-vbscript
a VBScript function that encrypts any string and reverses the process when it is executes twice times.
After addapt it to NeoBook enviroment the code is:
(Save it into your VBScript Functions Folder as EnDeCrypt)
Code: Select all
{NeoBook Function}
Version=5.80
Language=VBScript
Param=[%1]|Text|Text to En/De Crypt
Param=[%2]|Text|Encrypt Key
Param=[%3]|Variable|Return Var
{End}
Dim sbox(255)
Dim key(255)
Dim Encryptkey
Dim EncryptStr
Dim Encryptedstr
EncryptStr = "[%1]"
Encryptkey = "[%2]"
Encryptedstr = EnDeCrypt(EncryptStr,Encryptkey)
publication.nbSetVar "[%3]", Encryptedstr
Sub RC4Initialize(strPwd)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: This routine called by EnDeCrypt function. Initializes the :::
'::: sbox and the key array) :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
dim tempSwap
dim a
dim b
intLength = len(strPwd)
For a = 0 To 255
key(a) = asc(mid(strpwd, (a mod intLength)+1, 1))
sbox(a) = a
next
b = 0
For a = 0 To 255
b = (b + sbox(a) + key(a)) Mod 256
tempSwap = sbox(a)
sbox(a) = sbox(b)
sbox(b) = tempSwap
Next
End Sub
Function EnDeCrypt(plaintxt, psw)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: This routine does all the work. Call it both to ENcrypt :::
'::: and to DEcrypt your data. :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
dim temp
dim a
dim i
dim j
dim k
dim cipherby
dim cipher
i = 0
j = 0
RC4Initialize psw
For a = 1 To Len(plaintxt)
i = (i + 1) Mod 256
j = (j + sbox(i)) Mod 256
temp = sbox(i)
sbox(i) = sbox(j)
sbox(j) = temp
k = sbox((sbox(i) + sbox(j)) Mod 256)
cipherby = Asc(Mid(plaintxt, a, 1)) Xor k
cipher = cipher & Chr(cipherby)
Next
EnDeCrypt = cipher
End Function
(Put this code into a button Actions Properties)
Code: Select all
InputBox "EnDeCrypt" "Text to convert" "[String]"
Call "EnDeCrypt" "[String]" "ThisIsAVeryLongKey" "[String]"
Could any do the improvement ? (and publicate here ?)
Thanks in advance,
David de Argentina