Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: Encryption

Results 1 to 8 of 8
Share This Thread →
  1. #1
    Guddu's Avatar
    Guddu is offline Contributing User
    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    988

    Encryption

    hi

    i am passing clientid through querystring.now what i want to do is to encrypt this id.

    my url is like this
    Code:
    https://www.shail.com/Portal/admin/clientadmin/employeeSummary/frameset.asp?lngClientID=1202&strPage=Summary
    any good way for encryption?
    thanx
    Nothing is Impossible bcoz IMPOSSIBLE itself says..
    I M POSSIBLE........................
    Be cool !!!!!!!!

  2. #2
    barneybabe's Avatar
    barneybabe is offline Contributing User
    Join Date
    Jun 2004
    Posts
    1,657
    Rep Power
    237
    I use the following simple encryption method

    Code:
    <%
    	//---This is to encrypt and decrypt
       Dim sbox(255)
       Dim key(255)
    
       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
    
    //================Usage
    
    //---this can be any text but use the same text to encrypt and decrypt
    psw = "anytext"
    //---To encrypt
    Enc = EnDeCrypt("hello" , psw) 
    response.write Enc &"<br>"
    //---to decrypt
    Dec= EnDeCrypt(Enc , psw) 
    response.write Dec &"<br>"
    %>
    Important note:- when you pass the encrypted value as querystring you have to use Server.URLEncode(encrptedvalue) otherwise it will not be correctly decrypted.
    Last edited by barneybabe; February 18th, 2008 at 11:03 PM.

  3. #3
    Guddu's Avatar
    Guddu is offline Contributing User
    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    988
    thanx for reply let me check

  4. #4
    Guddu's Avatar
    Guddu is offline Contributing User
    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    988
    hi i m getting divide by zero error at this line
    Code:
     key(a) = asc(mid(strpwd, (a mod intLength)+1, 1))

  5. #5
    barneybabe's Avatar
    barneybabe is offline Contributing User
    Join Date
    Jun 2004
    Posts
    1,657
    Rep Power
    237
    what is the pwd and the string you are trying to encrypt?

  6. #6
    Guddu's Avatar
    Guddu is offline Contributing User
    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    988
    now its working...i m not using server.urlencode but still working

  7. #7
    barneybabe's Avatar
    barneybabe is offline Contributing User
    Join Date
    Jun 2004
    Posts
    1,657
    Rep Power
    237
    It would be better you use the server.urlencode otherwise you may get into trouble later.

  8. #8
    Guddu's Avatar
    Guddu is offline Contributing User
    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    988
    okay thanx a lot

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

  1. Encryption in SSIS package
    By kmurlikrishna in forum Microsoft SQL Server
    Replies: 1
    Last Post: October 27th, 2006, 10:09 AM
  2. Encryption Problem
    By russ21282 in forum ASP Development
    Replies: 1
    Last Post: July 31st, 2006, 05:17 AM
  3. Symmetric encryption
    By kshinningstr in forum ASP Development
    Replies: 1
    Last Post: February 22nd, 2006, 08:29 PM
  4. Simple Encryption
    By freeasphelp in forum Code Bank
    Replies: 4
    Last Post: June 7th, 2005, 09:25 AM
  5. Coding for Browser Encryption
    By Steve Schofield in forum ASP Development
    Replies: 0
    Last Post: September 4th, 2001, 11:58 AM

ASP Free Advertisers and Affiliates