您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > ASP >

PHP数学运算代码转换成asp代码

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 05:40 点击:

今天考试过后(考的很悲剧),逛论坛看见一贴,说是转换一段asp代码为php代码:
01 <?php
02 function app_hash_url($url) {
03     $seed = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE.";
04     $result = 0x01020345;
05     for ($i=0; $i<strlen($url); $i++) {
06      $result ^= ord($seed{$i%87}) ^ ord($url{$i});
07      $result = (($result >> 23) & 0x1FF) | $result << 9;
08     }
09     return sprintf("8%x", $result);
10 }
11 $url="dddddd";
12 echo app_hash_url($url);
13 ?>
转换如下:
1.asp没有位移运算,百度了一个位移运算的类
2.格式化输出
01 <%
02 Class mShift
03 
04  Private m_lPower2(31)
05  
06  Public Function RShift(ByVal lThis, ByVal lBits)
07   On Error Resume Next
08   Init
09   If (lBits <= 0) Then
10      RShift = lThis
11   ElseIf (lBits > 63) Then
12      ' .. error ...
13   ElseIf (lBits > 31) Then
14      RShift = 0
15   Else
16      If (lThis And m_lPower2(31 - lBits)) = m_lPower2(31 - lBits) Then
17      RShift = (lThis And (m_lPower2(31 - lBits) - 1)) * m_lPower2(lBits)Or m_lPower2(31)
18      Else
19      RShift = (lThis And (m_lPower2(31 - lBits) - 1)) * m_lPower2(lBits)
20      End If
21   End If
22  End Function
23  
24  Public Function LShift(ByVal lThis, ByVal lBits)
25   On Error Resume Next
26   Init
27   If (lBits <= 0) Then
28      LShift = lThis
29   ElseIf (lBits > 63) Then
30      ' ... error ...
31   ElseIf (lBits > 31) Then
32      LShift = 0
33   Else
34      If (lThis And m_lPower2(31)) = m_lPower2(31) Then
35      LShift = (lThis And &H7FFFFFFF) \ m_lPower2(lBits) Or m_lPower2(31 - lBits)
36      Else
37      LShift = lThis \ m_lPower2(lBits)
38      End If
39   End If
40  End Function
41  
42  Private Sub Init()
43   On Error Resume Next
44   m_lPower2(0) = &H1&
45   m_lPower2(1) = &H2&
46   m_lPower2(2) = &H4&
47   m_lPower2(3) = &H8&
48   m_lPower2(4) = &H10&
49   m_lPower2(5) = &H20&
50   m_lPower2(6) = &H40&
51   m_lPower2(7) = &H80&
52   m_lPower2(8) = &H100&
53   m_lPower2(9) = &H200&
54   m_lPower2(10) = &H400&
55   m_lPower2(11) = &H800&
56   m_lPower2(12) = &H1000&
57   m_lPower2(13) = &H2000&
58   m_lPower2(14) = &H4000&
59   m_lPower2(15) = &H8000&
60   m_lPower2(16) = &H10000
61   m_lPower2(17) = &H20000
62   m_lPower2(18) = &H40000
63   m_lPower2(19) = &H80000
64   m_lPower2(20) = &H100000
65   m_lPower2(21) = &H200000
66   m_lPower

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • WAP常见问题问答大全(四)
      • ASP开发必备:WEB打印代码大全
      • ASP调用系统ping命令
      • asp缓存技术
      • ASP教程:第三篇 ASP基础
      • 用ASP+XML打造留言本(4)
      • 关于ASP Recordset 分页出现负数解决方法及建议
      • 用asp怎样编写文档搜索页面(5)
      • ASP处理多关键词查询实例代码
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1