由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - python/perl interesting question
相关主题
2007年9月编程语言指数Perl/Python/.NET难道是搞网页的?
Py2exe or Portable Python这个很奇怪
谢谢大家!One More Question! Re: C 程序计算结果花了一个小时学习了python
谁能说说Perl, Python, Tcl各自的优缺点?主要应用场合?python中那个function类似Perl或者PHP的die()?
Anybody using Python?[合集] 到底要学习Perl,还是Python?
你认为ubuntu下面写script,用perl还是python更好? (转载)[合集] 我也花了一小时读了一下python
Do you like perl style?现在是不是不该学python?
[合集] use Perl in C++?python, perl, C
相关话题的讨论汇总
话题: hex话题: perl
进入Programming版参与讨论
1 (共1页)
w*s
发帖数: 7227
1
say this is encryption, i have a key like this,
my $hexString = "D55A445A08C92C1208216D916AD839CE739CC10414119243FFE70B113C"
;
now i need to get rid of the last 3 bits,
basically
$newHexString = $hexString >> 3.
how can you do that ?
t****t
发帖数: 6806
2
$ perl -MMath::BigInt -e '$a=Math::BigInt->from_hex("
D55A445A08C92C1208216D916AD839CE739CC10414119243FFE70B113C")>>3; print $a->
as_hex, "\n";'
0x1aab488b4119258241042db22d5b0739ce739820828232487ffce16227

D55A445A08C92C1208216D916AD839CE739CC10414119243FFE70B113C"

【在 w*s 的大作中提到】
: say this is encryption, i have a key like this,
: my $hexString = "D55A445A08C92C1208216D916AD839CE739CC10414119243FFE70B113C"
: ;
: now i need to get rid of the last 3 bits,
: basically
: $newHexString = $hexString >> 3.
: how can you do that ?

t****t
发帖数: 6806
3
or even easier, write
$ perl -Mbigint -e '$a=
0xD55A445A08C92C1208216D916AD839CE739CC10414119243FFE70B113C>>3; print $a->
as_hex, "\n";'
0x1aab488b4119258241042db22d5b0739ce739820828232487ffce16227

D55A445A08C92C1208216D916AD839CE739CC10414119243FFE70B113C"

【在 w*s 的大作中提到】
: say this is encryption, i have a key like this,
: my $hexString = "D55A445A08C92C1208216D916AD839CE739CC10414119243FFE70B113C"
: ;
: now i need to get rid of the last 3 bits,
: basically
: $newHexString = $hexString >> 3.
: how can you do that ?

w*s
发帖数: 7227
4
厉害,谢谢!

【在 t****t 的大作中提到】
: or even easier, write
: $ perl -Mbigint -e '$a=
: 0xD55A445A08C92C1208216D916AD839CE739CC10414119243FFE70B113C>>3; print $a->
: as_hex, "\n";'
: 0x1aab488b4119258241042db22d5b0739ce739820828232487ffce16227
:
: D55A445A08C92C1208216D916AD839CE739CC10414119243FFE70B113C"

l********a
发帖数: 1154
5
跟python一样方便
>>> str(hex(0xD55A445A08C92C1208216D916AD839CE739CC10414119243FFE70B113C>>3))
'0x1aab488b4119258241042db22d5b0739ce739820828232487ffce16227L'
>>> str(hex(0xD55A445A08C92C1208216D916AD839CE739CC10414119243FFE70B113C>>3)
)[:-1]
'0x1aab488b4119258241042db22d5b0739ce739820828232487ffce16227'
1 (共1页)
进入Programming版参与讨论
相关主题
python, perl, CAnybody using Python?
[合集] 有没有什么工具可以把perl script转成别的语言?你认为ubuntu下面写script,用perl还是python更好? (转载)
[合集] 给没用过 python 或着这正在用的人Do you like perl style?
[合集] 能推荐几本C++/perl/Python 方面的好书吗?[合集] use Perl in C++?
2007年9月编程语言指数Perl/Python/.NET难道是搞网页的?
Py2exe or Portable Python这个很奇怪
谢谢大家!One More Question! Re: C 程序计算结果花了一个小时学习了python
谁能说说Perl, Python, Tcl各自的优缺点?主要应用场合?python中那个function类似Perl或者PHP的die()?
相关话题的讨论汇总
话题: hex话题: perl