demo.html 1.12 KB
<div class="encrypt-form">
    <div>
        <label for="encryptInput">加密前的字符:</label>
        <input id="encryptInput1" value="encrypt" />
    </div>
    <div>
        <label for="encryptInput">加密后的字符:</label>
        <input readonly="readonly" id="encryptInput2" value="" />
    </div>
    <a href="javascript:;" onclick="encrypt()">点击加密</a>
</div>
<style>
.encrypt-form {
    margin: 10px;
}
.encrypt-form > div {
    margin-bottom: 10px;
}
label, input {
    display: inline-block;
    height: 24px;
    line-height: 24px;
    vertical-align: middle;
}
input {
    padding-left: 7px;
    margin: 0;
    border: 1px solid #ccc;
    outline: none;
}
a {
    display: block;
    color: #108ee9;
    padding-left: 105px;
    text-decoration: underline;
}
</style>

<script>
function encrypt() {
    var encryptInput1 = document.getElementById("encryptInput1");
    var encryptInput2 = document.getElementById("encryptInput2");
    var encryptStr = encryptInput1.value;

    encryptInput2.value = "";
    Mobile_NS.encrypt(encryptStr, function (result) {
        encryptInput2.value = result;
    });
}
</script>