Files
browserPGP/encrypt.html
unknown c389d5baf5 monky
2018-11-07 16:25:17 +00:00

87 lines
3.3 KiB
HTML

<html>
<head>
<title>BrowserPGP | Encrypt</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="openpgp.min.js"></script>
<script>
openpgp.initWorker({ path:'openpgp.worker.min.js' }) // set the relative web worker path
const encryptDecryptFunction = async() => {
// put keys in backtick (``) to avoid errors caused by spaces or tabs
const pubkey = document.getElementById("pubKey").value
const options = {
message: openpgp.message.fromText(document.getElementById("text").value), // input as Message object
publicKeys: (await openpgp.key.readArmored(pubkey)).keys, // for encryption
}
console.log(options);
openpgp.encrypt(options).then(ciphertext => {
encrypted = ciphertext.data // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
document.getElementById("result").value = encrypted;
})
}
</script>
<style>
html, body {
height: 95%;
}
div.main {
padding:20px;
height: 100%;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="/">BrowserPGP</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="/encrypt.html">Encrypt</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/decrypt.html">Decrypt</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/gen.html">Key Generator</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">More to come.</a>
</li>
</ul>
</div>
</nav>
<div class="main">
<div class="container-fluid" style="height:100%;">
<div class="row" style="height:100%;">
<div class="col-sm" style="height:100%;">
<div class="form-group">
<label for="exampleFormControlTextarea1">Public Key</label>
<textarea class="form-control" style="font-size: 10px;height:100%;" id="pubKey" placeholder="-----BEGIN PGP PUBLIC KEY BLOCK-----"></textarea>
</div>
</div>
<div class="col-sm">
<div class="form-group">
<label for="exampleFormControlTextarea1">Input Text</label>
<textarea class="form-control" id="text" rows="5" placeholder="So basically, I'm monky."></textarea>
</div>
<button type="button" onclick="encryptDecryptFunction()" class="btn btn-primary">Encrypt</button>
</div>
<div class="col-sm" style="height:100%;">
<div class="form-group">
<label for="exampleFormControlTextarea1">PGP Output</label>
<textarea class="form-control" style="font-size: 10px;height:100%;" id="result" placeholder="-----BEGIN PGP MESSAGE-----" readonly></textarea>
</div>
</div>
</div>
</div>
</div>
</body>
</html>