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

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

问题描述

这是不是安全。它也不是使它难以突破。我在找一个简单的算法来改变一个字符串(URL)在某种程度上,它并不像原来的。在加密的将用JavaScript实现。然后,我要养活的加密的字符串到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. 将只使用小写的加密串字母字符和数字
  7. 在没有广泛使用一样的Base64荷兰国际集团作为加密的方法。
  1. will be simple
  2. will use available javascript functions for encryption
  3. will use available php functions for decryption
  4. will produce encrypted string in way not to resemble the plain text at all
  5. will only use lower-case alphabet characters and numbers in the encrypted string
  6. is not a method widely used like Base64-ing as encryption.

编辑:最后一个要求是在<一个加href="http://stackoverflow.com/questions/3609005/simple-javascript-encrypt-php-decrypt-with-shared-secret-key/3609068#3609068">shamittomar's的回答。

The last requirement was added after shamittomar's answer.

推荐答案

如果这是你想要的,你可以的Base64 连接code和德$ C C是$。

If that's what you want, you can Base64 encode and decode that.

:OP澄清后:

当你不希望广泛使用的方法,这里是一个很少的使用方法,并可以通过给输出仅在小写字母和数字为你做它。这是 Base32恩code /德code 。使用下列库:

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屋!

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