Add files via upload

This commit is contained in:
ar0n
2018-11-06 17:44:33 +00:00
committed by GitHub
parent fe0647bf3e
commit a55a09243d
4 changed files with 146 additions and 0 deletions

80
encrypt.html Normal file
View 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>

62
index.html Normal file
View File

@@ -0,0 +1,62 @@
<html>
<head>
<title>BrowserPGP</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="/">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="/encrypt.html">Encrypt</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">More to come.</a>
</li>
</ul>
</div>
</nav>
<div class="main">
<h1 class="display-4">BrowserPGP</h1>
<a>A little project that makes using PGP in a browser safe and secure.</a>
</div>
</body>
</html>

2
openpgp.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
openpgp.worker.min.js vendored Normal file
View File

@@ -0,0 +1,2 @@
/*! OpenPGP.js v4.2.1 - 2018-11-06 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
!function(){return function e(n,r,t){function o(a,f){if(!r[a]){if(!n[a]){var u="function"==typeof require&&require;if(!f&&u)return u(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var s=r[a]={exports:{}};n[a][0].call(s.exports,function(e){return o(n[a][1][e]||e)},s,s.exports,e,n,r,t)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a<t.length;a++)o(t[a]);return o}}()({1:[function(e,n,r){self.window=self,importScripts("openpgp.min.js");var t=window.openpgp,o=[],i=6e4;function a(e){self.postMessage(e,t.util.getTransferables(e.data))}t.crypto.random.randomBuffer.init(i,function(){return o.length||self.postMessage({event:"request-seed",amount:i}),new Promise(function(e){o.push(e)})}),self.onmessage=function(e){var n,r=e.data||{};switch(r.event){case"configure":n=r.config,Object.keys(n).forEach(function(e){t.config[e]=n[e]});break;case"seed-random":!function(e){e instanceof Uint8Array||(e=new Uint8Array(e));t.crypto.random.randomBuffer.set(e)}(r.buf);var i=o;o=[];for(var f=0;f<i.length;f++)i[f]();break;default:!function(e,n,r){if("function"!=typeof t[n])return void a({id:e,event:"method-return",err:"Unknown Worker Event"});r=t.packet.clone.parseClonedPackets(r,n),t.util.restoreStreams(r),t[n](r).then(function(n){a({id:e,event:"method-return",data:t.packet.clone.clonePackets(n)})}).catch(function(n){t.util.print_debug_error(n),a({id:e,event:"method-return",err:n.message,stack:n.stack})})}(r.id,r.event,r.options||{})}}},{}]},{},[1]);