将 Perl 函数转换为 PHP
我想将下面的 perl 函数转换为 PHP 函数,如果有人可以提供一点帮助,我将不胜感激:
sub encode32
{
$_=shift;
my($l,$e);
$_=unpack('B*',$_);
s/(.....)/000$1/g;
$l=length;
if($l & 7)
{
$e=substr($_,$l & ~7);
$_=substr($_,0,$l & ~7);
$_.="000$e" . '0' x (5-length $e);
}
$_=pack('B*', $_);
tr|\0-\37|A-Z2-7|;
lc($_);
}
提前致谢。
I want to convert the perl function below to PHP function, if someone could help a little bit I'd appreaciate it:
sub encode32
{
$_=shift;
my($l,$e);
$_=unpack('B*',$_);
s/(.....)/000$1/g;
$l=length;
if($l & 7)
{
$e=substr($_,$l & ~7);
$_=substr($_,0,$l & ~7);
$_.="000$e" . '0' x (5-length $e);
}
$_=pack('B*', $_);
tr|\0-\37|A-Z2-7|;
lc($_);
}
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它是 RFC 3548 的 Base32 编码的本地实现。根据 GPL 条款分发的 PHP 实现可在 Fremnet 上找到。
使用示例:
输出:
It's a homegrown implementation of the Base32 encoding from RFC 3548. A PHP implementation distributed under the terms of the GPL is available at Fremnet.
Example use:
Output: