我在PHP.net上看到MD5没用,他们建议使用crypt + salt.
所以,我去了他们的功能描述并阅读
<?php
$password = crypt('mypassword'); // let the salt be automatically generated
/* You should pass the entire results of crypt() as the salt for comparing a
password, to avoid problems when different hashing algorithms are used. (As
it says above, standard DES-based password hashing uses a 2-character salt,
but MD5-based hashing uses 12.) */
if (crypt($user_input, $password) == $password) {
echo "Password verified!";
}
?>
Run Code Online (Sandbox Code Playgroud)
或者在我的情况下:
$stored_password=fetch_password($user);
if (crypt($_REQUEST['password'],$stored_password)===$stored_password) {
// ok
}
Run Code Online (Sandbox Code Playgroud)
因此,当我看到salt存储在散列密码中并且您使用散列密码作为salt时,我认为Crypt + Salt对于输出上的暴力(黑客成功窃取哈希密码)并不安全.它更安全吗? …
我知道我们可以使用类似的东西解析CSV行(';'分隔符):
delim = ';'
myline="i;want;to;know;what;love;is"
parse var myline w1 (delim) w2 (delim) w3 (delim) w4 (delim) w5 (delim) w6 (delim) w7
say w1 w2 w3 w4 w5 w6 w7
Run Code Online (Sandbox Code Playgroud)
我想知道是否有办法简化'w#(delim)'的迭代,以便做类似的事情:
parse var myline w1 (delim) w2 (delim) ... (delim) w6 (delim) w7
/* then we will have all w1 to w7 defined
Run Code Online (Sandbox Code Playgroud)
我可以用一些数组做一个函数来做到这一点,但它可能本身就在rexx上,我只是想知道
谢谢
我正在学习Perl.
我在文件上看到了一个使用函数"do"的脚本.然后我读到了关于该功能:
如果可以读取文件但无法编译它,则返回undef并在$ @中设置错误消息.如果无法读取文件,则返回undef并设置$!错误.始终检查$ @,因为编译可能会以同样设置$的方式失败!.如果文件成功编译,请返回最后一个表达式的值.
最好使用use和require运算符来包含库模块,如果出现问题,还会执行自动错误检查并引发异常.
您可能希望使用do来读取程序配置文件.可以通过以下方式进行手动错误检查:您可能希望使用do来读取程序配置文件.手动错误检查可以这样做:
Run Code Online (Sandbox Code Playgroud)# read in config files: system first, then user for $file ("/share/prog/defaults.rc", "$ENV{HOME}/.someprogrc") { unless ($return = do $file) { warn "couldn't parse $file: $@" if $@; warn "couldn't do $file: $!" unless defined $return; warn "couldn't run $file" unless $return; } }
我不明白为什么他们在谈论编译配置文件?它是什么样的配置文件?为什么/何时使用该配置文件?
谢谢
在Windows的行尾是\ r \n(x0dx0a)例如(2行文本)textfile.txt:
abc
def
Run Code Online (Sandbox Code Playgroud)
我原本以为每行都是lenght == 5.但是当我尝试读取函数时,似乎我们需要考虑每行有3 + 1个字符(长度== 4).将换行计为1个字符(作为x0a).
我想知道有没有办法让perl读取文件的每个八位字节(也读取x0d)?
我不确定它是否有用,但我只是想知道^ _ ^
谢谢