How to understand PHP encryption function Javascript/Js decryption function
This article focuses on "how to understand the PHP encryption function Javascript/Js decryption function", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to understand the PHP encryption function Javascript/Js decryption function"!
"123456" in the following function code is an encrypted key, which you can change at will.
Php encryption, js decryption, seems to be meaningless, mainly key will be seen in js.
But it may be used in some places.
PHP encryption function
The copy code is as follows:
Js decryption function:
The copy code is as follows:
Function strencode (string) {
Key = calcMD5 ('123456')
String = Base64.decode (string)
Len = key.length
Code =''
For (I = 0; I < string.length; iTunes +) {
K = I% len
Code + = String.fromCharCode (string.charCodeAt (I) ^ key.charCodeAt (k))
}
Return Base64.decode (code)
}
Alert (strencode ('PGZ6Cz40Z1JCWCYNRVtSDwsvfVsIexpcEFN0DU0OSQkXQUIPCQxnV1NLDA9SSw8PF1JhWxAHZ18FAGIncUFiFS5yWxAuClxUf15fXA=='))
PHP encryption & JS decryption 2
The copy code is as follows: