Add files via upload
This commit is contained in:
80
encrypt.html
Normal file
80
encrypt.html
Normal file
@@ -0,0 +1,80 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Encrypt PGP</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="#">PGP Tools</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 <span class="sr-only">(current)</span></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"></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"></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" readonly></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user