奇怪的散列比赛都在bash脚本编程时间 [英] strange hashing match all the time in bash scripting
问题描述
#!/斌/庆典
猜=`awk的'{打印$ 1}password`
尝试= $(回声$猜测| sha256sum)
测试=f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2
如果[$尝试==$测试]
然后
回声密码$猜
其他
回声密码找不到
科幻
所以我想从密码文件中的第一行的值,并且使用sha256sum获得哈希值,比较,我已经给了,如果它们是相同的,这意味着我发现密码值散列值。然而,当我尝试运行它,它变得疯狂,如果我设置密码,第一个值是ABC,输出将是密码为abc,如果我的值设置为你好,输出会是个招呼。它没有意义。
如果[$尝试==$测试]
这code的语法错误,我不应该做之间的空间,$试试,$测试也是我需要给间距和==。
修正:
如果[$尝试==$测试]
#!/bin/bash
guess=`awk '{print $1}' password`
try=$(echo "$guess" | sha256sum)
testing="f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2"
if [" $try "==" $testing "]
then
echo "the password is $guess"
else
echo "password not found"
fi
So i am trying to get first line value from password file, and using sha256sum to get the hashing value, and compare the hashing value with the value that i already given, if they are the same, it means i found the password. However, when i try to run it, it became crazy, if i set first value in password to be "abc", the output will be "the password is abc", if i set the value to be "hello", output will be hello. It doesn't make sense.
if [" $try "==" $testing "]
this code has syntax errors, i should not make space between " and $try,$testing also i need to give space between " and ==.
Corrected:
if [ "$try" == "$testing" ]
这篇关于奇怪的散列比赛都在bash脚本编程时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!