这与安全无关.也不是让它难以打破.我正在寻找一种简单的算法来以一种与原始字符串不同的方式更改字符串(网址).加密 将使用 javascript 完成.然后我想将 encrypted 字符串提供给 PHP 函数以将其更改回原始字符串.两端可以共享一个密钥,或者转换可以是无密钥的,只依赖于逻辑.
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.
理想的解决方案
最后一个要求是在shamittomar 的回答.
The last requirement was added after shamittomar's answer.
如果这正是您想要的,您可以Base64 对其进行编码和解码.
If that's what you want, you can Base64 encode and decode that.
:在 OP 澄清之后:
由于您不想要广泛使用的方法,这里有一种很少使用的方法,它可以通过仅以小写字母和数字给出输出来为您完成.它是Base32 编码/解码.使用以下库:
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 加密,PHP 使用共享密钥解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!