怎么给url后面的 id加密解密

luomingchu 2007-06-30 01:52:33
请问各位怎么给一个地址后面的id 加密解密
比如 http://community.csdn.net/IndexPage/NewTopic.aspx?id=sdjfkeijgdjifeijfkdsj

那传过去后怎么在把接受过来的加密内容解密??
?有没有这样的代码呢?
...全文
1545 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
good_17 2010-03-20
  • 打赏
  • 举报
回复
学习学习
mark
brilliant_fgh 2010-03-20
  • 打赏
  • 举报
回复
给要传递的ID相对应的产生一个随机字符串(最好字母和时间一起,不会重复),在接收页面通过这个字符串再找到这个ID,要用到数据库!
个人觉得这样要简单一点!
G_Rose 2010-03-20
  • 打赏
  • 举报
回复
学习学习
yuys168 2010-03-17
  • 打赏
  • 举报
回复
顶回复内容太短了!
ImFantasy 2010-03-16
  • 打赏
  • 举报
回复
楼主去研究一下PHPCMS2008的代码, 他有这个功能.
y9902 2007-07-03
  • 打赏
  • 举报
回复
个人意味 urlencode或base64_encode 都不算是加密,只是编码而已. 熟悉的人一看就知道采用什么编码,然后采用相应的解码函数就可以揭开,达不到加密的作用

其实 php 有个Mcrypt库,自带很多加密函数, 只要自己弄个 密钥, 就可以进行可逆加密.
Here is a list of ciphers which are currently supported by the mcrypt extension. For a complete list of supported ciphers, see the defines at the end of mcrypt.h. The general rule with the mcrypt-2.2.x API is that you can access the cipher from PHP with MCRYPT_ciphername. With the libmcrypt-2.4.x and libmcrypt-2.5.x API these constants also work, but it is possible to specify the name of the cipher as a string with a call to mcrypt_module_open().

MCRYPT_3DES
MCRYPT_ARCFOUR_IV (libmcrypt > 2.4.x only)
MCRYPT_ARCFOUR (libmcrypt > 2.4.x only)
MCRYPT_BLOWFISH
MCRYPT_CAST_128
MCRYPT_CAST_256
MCRYPT_CRYPT
MCRYPT_DES
MCRYPT_DES_COMPAT (libmcrypt 2.2.x only)
MCRYPT_ENIGMA (libmcrypt > 2.4.x only, alias for MCRYPT_CRYPT)
MCRYPT_GOST
MCRYPT_IDEA (non-free)
MCRYPT_LOKI97 (libmcrypt > 2.4.x only)
MCRYPT_MARS (libmcrypt > 2.4.x only, non-free)
MCRYPT_PANAMA (libmcrypt > 2.4.x only)
MCRYPT_RIJNDAEL_128 (libmcrypt > 2.4.x only)
MCRYPT_RIJNDAEL_192 (libmcrypt > 2.4.x only)
MCRYPT_RIJNDAEL_256 (libmcrypt > 2.4.x only)
MCRYPT_RC2
MCRYPT_RC4 (libmcrypt 2.2.x only)
MCRYPT_RC6 (libmcrypt > 2.4.x only)
MCRYPT_RC6_128 (libmcrypt 2.2.x only)
MCRYPT_RC6_192 (libmcrypt 2.2.x only)
MCRYPT_RC6_256 (libmcrypt 2.2.x only)
MCRYPT_SAFER64
MCRYPT_SAFER128
MCRYPT_SAFERPLUS (libmcrypt > 2.4.x only)
MCRYPT_SERPENT(libmcrypt > 2.4.x only)
MCRYPT_SERPENT_128 (libmcrypt 2.2.x only)
MCRYPT_SERPENT_192 (libmcrypt 2.2.x only)
MCRYPT_SERPENT_256 (libmcrypt 2.2.x only)
MCRYPT_SKIPJACK (libmcrypt > 2.4.x only)
MCRYPT_TEAN (libmcrypt 2.2.x only)
MCRYPT_THREEWAY
MCRYPT_TRIPLEDES (libmcrypt > 2.4.x only)
MCRYPT_TWOFISH (for older mcrypt 2.x versions, or mcrypt > 2.4.x )
MCRYPT_TWOFISH128 (TWOFISHxxx are available in newer 2.x versions, but not in the 2.4.x versions)
MCRYPT_TWOFISH192
MCRYPT_TWOFISH256
MCRYPT_WAKE (libmcrypt > 2.4.x only)
MCRYPT_XTEA (libmcrypt > 2.4.x only)
rjzou2006 2007-07-03
  • 打赏
  • 举报
回复
加密的话,肯定要自己写一个,别人才破不了的
ai_ni 2007-07-02
  • 打赏
  • 举报
回复
自己写个加密接密函数..
yiheng_l 2007-07-02
  • 打赏
  • 举报
回复
自己写的,给你参考参考

//参数编码加密类
class coding
{
/*
加密时调用“return_coding”方法
解密时调用“converse_str”方法
注意参数
*/
//构造函数
function coding()
{
$this->coding_str = array(
'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t',
'u','v','w','x','y','z','0','1','2','3',
'4','5','6','7','8','9','8','7','6','5',
'4','3','2','1','0','1','2','3','4','5'
);
}

//生成数组,加密并返回
/*$num_l:加密位数,整型,比如“3”
$page_key:私匙密钥,字符串,比如“aabbcc”
$Skey:私匙密钥,字符串,比如“aabbcc”*/
function return_coding($num_l,$page_key,$Skey)
{
$str_len = count($this->coding_str)-1;
$Z_str = "";
for($i=0;$i<$num_l;$i++)
{
$num = rand(0,$str_len);
$Z_str .= $this->coding_str[$num];
}
$Z_str .= $page_key;
for($i=0;$i<$num_l;$i++)
{
$num = rand(0,$str_len);
$Z_str .= $this->coding_str[$num];
}
$Z_str = $this->encrypt($Z_str,$Skey); //加密运算
return $Z_str;
}

//数组逆向解出
/*$num_l:加密位数,整型,比如“3”
$page_key:页面参数
$Skey:私匙密钥,字符串,比如“aabbcc”*/
function converse_str($num_l,$page_key,$Skey)
{
$page_key_h = $this->decrypt($page_key,$Skey); //解密运算
$key_len = strlen($page_key_h) - $num_l*2;
return substr($page_key_h,$num_l,$key_len);
}

//加密算法函数
function encrypt($code,$Skey)
{
$code = base64_encode(strrev(str_rot13($code)));
$code = (string)$code;
$c_l = strlen($code);
$s_m = $Skey;
$s_l = strlen($m);
$a=0;
while ($a <$c_l)
{
$str .= sprintf ("%'02s",base_convert(ord($code{$a})+ord($s_m{$s_l % $a+1}),10,32));
$a++;
}
return $str;
}

//解密算法函数
function decrypt($code,$Skey)
{
preg_match_all("/.{2}/", $code, $arr);
$arr = $arr[0];
$s_m = $Skey;
$s_l = strlen($m);
$a = 0;
foreach ($arr as $value)
{
$str .= chr(base_convert($value,32,10)-ord($s_m{$s_l % $a+1}));
$a++;
}
$str = str_rot13(strrev(base64_decode($str)));
return $str;
}
}
zhys9 2007-06-30
  • 打赏
  • 举报
回复
自己写咯,如果不需要加密的话就用base64_encode/base64_decode
lvlfforever 2007-06-30
  • 打赏
  • 举报
回复
urlencode或base64_encode都可以,或者自己写个简单的加密解密函数。
到了要取的地方调用对应的解密函数就行了。

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧