简单的Javascript加密,PHP使用共享密钥进行解密 [英] Simple Javascript encrypt, PHP decrypt with shared secret key
问题描述
这不是关于安全性。也不难打破。我正在寻找一个简单的算法来改变一个字符串(一个url),它不像原来的那样。 加密将使用javascript完成。然后,我想将加密的字符串提供给PHP函数,将其更改为原始。两端可以共享一个密钥,或者转换可以是无钥匙的,只能依靠逻辑。
理想的解决方案
- 将很简单
- 将使用可用的JavaScript函数进行加密
- 将使用可用的php函数解密
- 将生成加密字符串,不会像纯文本一样
- 只会使用加密的小写字母和数字字符串
- 不是像Base64-ing一样被广泛使用的加密方式。
编辑:最后一个要求是在 shamittomar
如果这是你想要的,你可以 Base64 编码和解码
:OP澄清后: / p>
由于您不需要广泛使用的方法,以下是一种很少使用的方法,可以通过仅在LOWERCASE字母中输出输出和NUMBERS。 Base32编码/解码 。使用以下库:
- Javascript Base32 Encoder: http://www.tumuski.com/2010/04/nibbler/
- PHP Base32解码器:
This is not about security. It is also not to make it hard to break. I'm looking for a simple algorithm to change a string (a url) in a way it does not resemble the original. The encryption will be done with javascript. Then I want to feed the encrypted string to a PHP function to change it back to the original. Both ends could share a secret key, or the conversions could be key-less and rely on just logic.
The ideal solution
- will be simple
- will use available javascript functions for encryption
- will use available php functions for decryption
- will produce encrypted string in way not to resemble the plain text at all
- will only use lower-case alphabet characters and numbers in the encrypted string
- is not a method widely used like Base64-ing as encryption.
Edit: The last requirement was added after shamittomar's answer.
解决方案If that's what you want, you can Base64 encode and decode that.
[EDIT]: After OP clarification:
As you do not want widely used methods, here is one rarely used method and that can do it for you by giving output only in LOWERCASE letters and NUMBERS. It is Base32 Encode/Decode. Use the following libraries:
- Javascript Base32 Encoder: http://www.tumuski.com/2010/04/nibbler/
- PHP Base32 Decoder: http://php-classes.de/class/base32/
这篇关于简单的Javascript加密,PHP使用共享密钥进行解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!