Home > Backend Development > PHP Tutorial > php问两个简单有关问题(json/php加密)

php问两个简单有关问题(json/php加密)

WBOY
Release: 2016-06-13 13:27:21
Original
1021 people have browsed it

php问两个简单问题(json/php加密)
1:我看一些大网站源码里总有一些这样
$t={ "programmers": [
  { "firstName": "Brett", "lastName":"McLaughlin", "email": "aaaa" },
  { "firstName": "Jason", "lastName":"Hunter", "email": "bbbb" },
  { "firstName": "Elliotte", "lastName":"Harold", "email": "cccc" }
  ],
  "authors": [
  { "firstName": "Isaac", "lastName": "Asimov", "genre": "science fiction" },
  { "firstName": "Tad", "lastName": "Williams", "genre": "fantasy" },
  { "firstName": "Frank", "lastName": "Peretti", "genre": "christian fiction" }
  ],
  "musicians": [
  { "firstName": "Eric", "lastName": "Clapton", "instrument": "guitar" },
  { "firstName": "Sergei", "lastName": "Rachmaninoff", "instrument": "piano" }
  ] }
这些json数据如何使用呢,为啥不用模板的时候就全替换好呢,有啥好处?
2:PHP想加密两串字符串
一是页面间用户识别的SESSION如何处理好更安全,传个用户名md5值再加一位数字好吗?
二是想加一串URL后面的/gallery/abcdefg12345.jpg
jpg可以静态去掉,这个图片名称加成啥好看些

------解决方案--------------------
1,就是普通的json串啊,你想表达什么意思,json_encode,json_decode。
2,一,SESSION在服务端,本来就安全。 二,可以重写,不过有意义吗,谁会去重写静态图片?
------解决方案--------------------
google:json 数据库。
------解决方案--------------------
加密就那么几种,看着有用的来就行,要高级加密那就涉及密钥了:

PHP code

$str1 ="abcabc123123";//加为纯数字或是纯字母
$str2 = "我是中国人";//这句也一样有效吗

echo md5($str1)."<br>";    #8709a6a92a8d441868d916b9ea2c07c2
echo md5($str2)."<br>";    #512d1643ba2878bc9c9f8f4f492673df

echo urlencode($str1)."<br>";    #abcabc123123
echo urlencode($str2)."<br>";    #%E6%88%91%E6%98%AF%E4%B8%AD%E5%9B%BD%E4%BA%BA

echo base64_encode($str1)."<br>";    #YWJjYWJjMTIzMTIz
echo base64_encode($str2)."<br>";    #5oiR5piv5Lit5Zu95Lq6 <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template