首页 > 解决方案 > 使用 javascript 从字符串返回 SHA-256 哈希

问题描述

我对 javascript 和 HTML 非常陌生。任何帮助表示赞赏。

这是一个简单的网页,旨在从字符串输入中返回 SHA-256。代码已从此处撕下并简化

https://www.fileformat.info/tool/hash.htm

代码

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript" ></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
</head>
<body 
<hr />
        <legend>String hash</legend>
        <form action="hash.htm" class="form-horizontal" method="post" name="theForm">
            <fieldset>
                <div class="control-group">
                    <label class="control-label" for="text">Text:</label>
                    <div class="controls">
                        <input type="text" class="span12" name="text" value="" />
                    </div>
                </div>
                <div class="control-group">
                    <div class="controls">
                        <input class="btn btn-primary" type="submit" value="Hash" />
                    </div>
                </div>
            </fieldset>
        </form>
    </div>
</div>
<table class="table table-bordered table-striped table-auto">
    <tr>
        <th colspan="2">Results</th>
    </tr>
    <tr>
        <td>SHA-256</td>
        <td></td>
    </tr>
</table>
</body>
</html>

当我将此代码保存为 .html 并使用浏览器打开它,然后尝试返回一个哈希值时,我被带到一个 404 not found 页面。

我敢肯定这很简单!谢谢!

标签: javascripthtmlhashsha

解决方案


推荐阅读