Cast 128 ActiveX component v1.1A simple Cast128 encryption/decryption component usable with ASP. It
also is a base64 codec. Informations: (C) & Disclaimer |
||||||||||||||||||||||||
The Cast128 implementation used in this component was made outside the USA. | ||||||||||||||||||||||||
Index1. Installation
1. InstallationTo install this component 1) copy the cast.dll file in any system folder (c:\windows or c:\winnt
or c:\winnt\system32 or so) To uninstall this component 1) there isn't a clean way to uninstall. 2. Documentation |
||||||||||||||||||||||||
This component use Cast128 to encrypt data. Cast is a simmetric algorithm,
so you must use the same key to encrypt and decrypt data. This component was created to encrypt importants data sent with cookies. To create an istance of the cipher class use the simbolic name
"cast.cipher" or the CLSID {12BBFB97-0AEC-4837-8061-12CA8EAD166B} To create an instance using VB/VBS:
The cipher class support this methods: 1) VARIANT cast128encode(VARIANT
key, VARIANT inString)
VARIANT cast128encode(VARIANT key, VARIANT inString) Encrypt a string using the specified key. Return a base64 encoded string. Use cast128ArrayEnc if you want to encrypt arrays. Parameters:
Returned value: The string returned is contained in a VARIANT.
VARIANT cast128decode(VARIANT key, VARIANT inBase64String) Decrypt a cast128 encrypted string generated by cast128ecode(). Return the original string. If you want to decrypt arrays use cast128ArrayDec. Parameters:
Returned value:
VARIANT cast128ArrayEnc(VARIANT key, VARIANT inArray) Encrypt an array of bytes usinge the key specified. Return an array containing the encrypted data. if you want encrypt strings use cast128encode. Parameters:
Returned value:
VARIANT cast128ArrayDec(VARIANT key, VARIANT inArray) Decrypt an array of bytes usinge the key specified. Return an array containing the decrypted data. if you want decrypt strings use cast128decode. Parameters:
Returned value:
VARIANT b64StrEnc(VARIANT inString) Encode a string using base64. The output is a string containing only
this chars: Parameters:
Returned value:
VARIANT b64StrDec(VARIANT inBase64String) Decode a string using base64. The output is the original string. If you want to decode arrays use b64ArrayDec. Parameters:
Returned value:
VARIANT b64ArrayEnc(VARIANT inArray) Encode an array of bytes using base64. The output is a string containing
only base64 chars: Parameters:
Returned value:
VARIANT b64ArrayDec(VARIANT inBase64String) Decode a base64 string. The output is an array of bytes. If you want to decode strings use b64StrDec. Parameters:
Returned value:
VARIANT encode(VARIANT key, VARIANT inString) An alias for cast128encode.
An alias for cast128decode.
3. Exaples of useCast Encrypt and Decrypt of a string in Visual
Basic: Set ObjCast = CreateObject("cast.cipher") Dim tkey As Variant Dim original As Variant Dim encodedText As Variant Dim decodedText As Variant tkey = "the Key" original = "Encoded Text" encodedText = ObjCast.cast128encode(tkey, original) decodedText = ObjCast.cast128decode(tkey, encodedText) msgbox("Original Data:" & original & vbNewline & "Encoded Data: " & encodedText & vbNewline & _ "Decoded Data: " & decodedText) Set ObjCast = Nothing Cookies with ASP VBScript: Setting an Encrypted cookie set objCast128 = server.createObject("cast.cipher") response.cookies("CookieName")("server") = objCast128.cast128encode("pass", "www.anon.net" ) response.cookies("CookieName")("login") = objCast128.cast128encode("pass", "myname") response.cookies("CookieName")("password") = objCast128.cast128encode("pass","mypassword") Response.Cookies("CookieName").Expires = dateadd("d",10,date) Response.Cookies("maiCookieNamelclient").Domain = "www.anon.net" Response.Cookies("CookieName").Path = "/" Response.Cookies("CookieName").Secure = falseGetting an Encrypted cookie set objCast128 = server.createObject("cast.cipher") encodedLogin = request.cookies("CookieName")("login") encodedPassword = request.cookies("CookieName")("password") encodedServer = request.cookies("CookieName")("server") Login = objCast128.cast128decode("pass", encodedLogin ) Password = objCast128.cast128decode("pass", encodedPassword ) MyServer = objCast128.cast128decode("pass", encodedServer )Base64 encoding and decoding of array in ASP VBScript: set objCast128 = server.createObject("cast.cipher") OriginalArray = Array(1, 3, 90, 23, 66, 3) strB64EncodedArray = objCast128.b64ArrayEnc(OriginalArray) DecodedArray = objCast128.b64ArrayDec(strB64EncodedArray) response.write("Original data: " & OriginalArray(0) & ", " & OriginalArray(1) & _ ", " & OriginalArray(2) & ", " & OriginalArray(3) & ", " & OriginalArray(4) & _ ", " & OriginalArray(5) & ) response.write("Base64 Encoded Data: " strB64EncodedArray & ) response.write("Decoded data: " & DecodedArray(0) & ", " & DecodedArray(1) & _ ", " & DecodedArray(2) & ", " & DecodedArray(3) & ", " & DecodedArray(4) & _ ", " & DecodedArray(5) & )Cast encrypt and decrypt of array in ASP VBScript: set objCast128 = server.createObject("cast.cipher") OriginalArray = Array(1, 3, 90, 23, 66, 3) Key = "the Key" Cast128EncryptedArray = objCast128.cast128ArrayEnc(Key,OriginalArray) DecryptedArray = objCast128.b64ArrayDec(key, Cast128EncryptedArray) response.write("Original data: " & OriginalArray(0) & ", " & OriginalArray(1) & _ ", " & OriginalArray(2) & ", " & OriginalArray(3) & ", " & OriginalArray(4) & _ ", " & OriginalArray(5) ) response.write("Encrypted data: " & Cast128EncryptedArray(0) & ", " & Cast128EncryptedArray(1) & _ ", " & Cast128EncryptedArray(2) & ", " & Cast128EncryptedArray(3) & ", " & _ Cast128EncryptedArray(4) & ", " & Cast128EncryptedArray(5) ) response.write("Decrypted data: " & DecryptedArray(0) & ", " & DecryptedArray(1) & _ ", " & DecryptedArray(2) & ", " & DecryptedArray(3) & _ ", " & DecryptedArray(4) & ", " & DecryptedArray(5))
Midori, Paipai Networks, Dec 2000. |