Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Base32/Base36 (or even Base62)encoding/decoding
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 14 February 2005 :  14:54:04  Show Profile  Visit MarcelG's Homepage
See http://www.oxle.com/topic.asp?TOPIC_ID=2283.

I've googled and googled and googled, but I cannot find a Base32/Base36 encoding/decoding script written in ASP anywhere...

...perhaps someone has some off-the-shelve-script laying around for this??
(Oh, I don't think Base64 is usable for the purpose because of the / that's used)...

portfolio - linkshrinker - oxle - twitter

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 16 February 2005 :  06:00:43  Show Profile  Visit MarcelG's Homepage
Erm...
I've found something but it's all in VB, and not ASP.
mmm...

portfolio - linkshrinker - oxle - twitter
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 18 February 2005 :  11:09:52  Show Profile  Visit MarcelG's Homepage
For those who're interested ; here's a script that works.

I've found some good code to do it, at Programmers Heaven!!! (notice the last part of the url?? yes, it's base62-encoded!!! )
I've worked it into a piece of ASP code:
<%
Const kBase62Digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

Function ToBase62(ByVal lInput)
    Dim lModulo
    Dim sTemp

    Do Until lInput = 0                                
        lModulo = lInput Mod 62                        
        sTemp = Mid(kBase62Digits, lModulo + 1, 1) & sTemp
        lInput = lInput \ 62                           
    Loop
    ToBase62 = sTemp                                   
End Function

Function FromBase62(ByVal sInput)
    Dim sR
    Dim i,iY,lLen
    Dim zMultiplier

    zMultiplier = 1                                    
    lLen = Len(sInput)                                 
    For i = lLen To 1 Step -1                          
        sR = Mid(sInput, i, 1)                         
        iY = InStr(1, kBase62Digits, sR, vbBinaryCompare) - 1
        FromBase62 = FromBase62 + iY * zMultiplier   
        zMultiplier = zMultiplier * 62                 
    Next
End Function
%>


I've incorporated it into the Link Shrinker, and it works as a charm!

portfolio - linkshrinker - oxle - twitter
Go to Top of Page

ajhvdb
Junior Member

Netherlands
392 Posts

Posted - 19 February 2005 :  11:53:51  Show Profile
thx, i need something like this. Does this convert all chars or only the normal ones? I think i can use this to convert a url with a foldername like:
...?DIR=C:\DATA\Folder1

to:
...?DIR=kjl132234kljlk45jkhj
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 19 February 2005 :  12:29:11  Show Profile  Visit MarcelG's Homepage
No, it converts a Base10 number (decimal) to a base62 number (0-9 + A-Z + a-z)
So, it's not for converting things like words etc.
You might want to use MD5 encoding for that purpose, however, links will be longer then if I'm not mistaking.

portfolio - linkshrinker - oxle - twitter
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.19 seconds. Powered By: Snitz Forums 2000 Version 3.4.07