Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
  
</head>
<body>
<form class="form-narrow form-horizontal" id="signupForm" method="post">
    <!--/* Show general error message when form contains errors */-->
    <th:block th:if="${#fields.hasErrors('${signupForm.*}')}">
        <div th:replace="fragments/alert :: alert (type='danger', message='Form contains errors. Please try again.')">
            Alert
        </div>
    </th:block>
    <fieldset>
        <legend>Please Sign Up</legend>
        <div class="form-group" th:classappend="${#fields.hasErrors('login')}? 'has-error'">
            <label for="login" class="col-lg-2 control-label">Login</label>
            <div class="col-lg-10">
                <input type="text" class="form-control" id="login" placeholder="Login" th:field="*{login}"/>
                <span class="help-block" th:if="${#fields.hasErrors('login')}"
                      th:errors="*{login}">Incorrect login</span>
            </div>
        </div>
        <div class="form-group" th:classappend="${#fields.hasErrors('password')}? 'has-error'">
            <label for="password" class="col-lg-2 control-label">Password</label>
            <div class="col-lg-10">
                <input type="password" class="form-control" id="password" placeholder="Password"
                       th:field="*{password}"/>
                <span class="help-block" th:if="${#fields.hasErrors('password')}" th:errors="*{password}">Incorrect password</span>
            </div>
        </div>
        <div class="form-group">
                <button onclick="javascript:test()" class="btn btn-default">Test JS</button>
            </div>
        </div>
    </fieldset>
</form>
</body>
</html>
 
        function test() {
            var userid = document.getElementById('login').value;
            var my_passphrase = document.getElementById('password').value;
            console.log('start');
            var F = kbpgp["const"].openpgp;
            var opts = {
                userid: userid,
                primary: {
                    nbits: 4096,
                    flags: F.certify_keys | F.sign_data | F.auth | F.encrypt_comm | F.encrypt_storage,
                    expire_in: 0  // never expire
                },
                subkeys: [
                    {
                        nbits: 2048,
                        flags: F.sign_data,
                        expire_in: 86400 * 365 * 8 // 8 years
                    }, {
                        nbits: 2048,
                        flags: F.encrypt_comm | F.encrypt_storage,
                        expire_in: 86400 * 365 * 8
                    }
                ]
            };
            console.log('before function');
            kbpgp.KeyManager.generate(opts, function(err, alice) {
                console.log('in function');
                if (!err) {
                    // sign alice's subkeys
                    alice.sign({}, function(err) {
                        console.log(alice);
                        // export demo; dump the private with a passphrase
                        alice.export_pgp_private ({
                            passphrase: my_passphrase
                        }, function(err, pgp_private) {
                            console.log("private key: ", priv);
                        });
                        alice.export_pgp_public({}, function(err, pgp_public) {
                            console.log("public key: ", pgp_public);
                        });
                    });
                } else {
                    console.log('error');
                }
            });
            console.log('finish');
        }
      
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers