Paip. Cross-platform cross-language custom encryption Method _php Tutorial

Source: Internet
Author: User
Paip. Cross-platform cross-language custom encryption method

Today is mainly to be in the ASP and PHP system module between the parameter transfer, for convenience, without MD5 signature, directly ready to use

DES encryption: However, the ASP and PHP des can not be added PIDM minimises secret ... Well, what's the CBC mode, iv vectors or something?

。 A lot of, adjusted for half a day or not, forget, or write your own encryption method it.

The main method of password encryption is to replace, shift. In addition, my requirement is that you also need to be able to use the key, and the algorithm

Simple.. Des algorithm A look is a big, MD, difficult to use. PASS ... Although the effect is good, a little complicated, not good rewrite ah

。。

Here, I conceived the idea of encrypting PIDM minimises secret:

1. Reverse the string first
2. Looping the string to the key group
3. The added result is converted to 16 binary characters. The main purpose is to save some space.
4. Return to the result ...
5. The decryption process can be reversed.

Dim key_l71723
key_l71723= "Iluvnjyn"
Dim msg
msg= "Admin"

Dim newstr
Newstr=atiencode (msg,key_l71723)
Response. Write (NEWSTR) ' shows that the encryption result is D7D5E2DACF
Response. Write (Atidecode (newstr,key_l71723))

---------------------------------------------
function Atiencode (Msg,key)

MSG=BACK_STR (msg) ' Invert string
Dim key_l71723
key_l71723= Key
key_l71723=key_l71723+key_l71723
key_l71723=key_l71723+key_l71723
key_l71723=key_l71723+key_l71723
Dim Msgarr
Msgarr=str2array (msg)
Dim Keyarr
Keyarr=str2array (key_l71723)
Dim newstr
Newstr= ""
' Add a loop to the key group
For i=0 to UBound (Msgarr)
Dim char
Char=msgarr (i)
Dim newchar ' int Format
Newchar = ASC (char) +ASC (Keyarr (i))
newchar= Hex (Newchar)

Newstr=newstr+cstr (Newchar)
Next

Atiencode=newstr
End Function

function Atidecode (Msg,key)

Dim key_l71723
key_l71723= Key
key_l71723=key_l71723+key_l71723
key_l71723=key_l71723+key_l71723
key_l71723=key_l71723+key_l71723
Dim Msgarr
Msgarr=str2arrayx (msg,2)
Dim Keyarr
Keyarr=str2array (key_l71723)
Dim newstr
Newstr= ""

For i=0 to UBound (Msgarr)
Dim charint

Charint=chn10 (Msgarr (i)) ' Encode Char

Dim Newchar www.2cto.com
NEWCHAR=CHR (CHARINT-ASCW (Keyarr (i)))
Newstr=newstr+newchar
Next

Newstr=back_str (NEWSTR)
Atidecode=newstr
End Function


Author: attilax

http://www.bkjia.com/PHPjc/478092.html www.bkjia.com true http://www.bkjia.com/PHPjc/478092.html techarticle Paip. Cross-platform cross-language custom encryption method today is mainly in the ASP and PHP system module for parameter transfer, in order to facilitate, without MD5 signature, directly prepared to use DES encryption. But ... ..

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.