简单的 Javascript 加密,PHP 使用共享密钥解密 [英] Simple Javascript encrypt, PHP decrypt with shared secret key

查看:26
本文介绍了简单的 Javascript 加密,PHP 使用共享密钥解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与安全无关.也不是让它难以打破.我正在寻找一种简单的算法来以一种与原始字符串不同的方式更改字符串(网址).加密 将使用 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.

理想的解决方案

  1. 会很简单
  2. 将使用可用的 javascript 函数进行加密
  3. 将使用可用的 php 函数进行解密
  4. 将生成与纯文本完全不同的加密字符串
  5. 将只在加密字符串中使用小写字母字符和数字
  6. 不是像 Base64-ing 那样广泛使用的加密方法.

最后一个要求是在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 使用共享密钥解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆