Simple Javascript encrypt, PHP decrypt with shared secret key(简单的 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.
理想的解决方案
- 会很简单
- 将使用可用的 javascript 函数进行加密
- 将使用可用的 php 函数进行解密
- 将生成与纯文本完全不同的加密字符串
- 将只在加密字符串中使用小写字母字符和数字
- 不是像 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 Base32 编码器:http://www.tumuski.com/2010/04/啃食者/
- PHP Base32 解码器:https://www.phpclasses.org/package/3484-PHP-Encode-and-decode-data-with-MIME-base-32-encoding.html
这篇关于简单的 Javascript 加密,PHP 使用共享密钥解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:简单的 Javascript 加密,PHP 使用共享密钥解密
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何替换eregi() 2022-01-01
