-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathencrypt.html
115 lines (111 loc) · 4.82 KB
/
encrypt.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<html>
<head>
<title>browserPGP | Encrypt</title>
<meta name="description" content="Encrypt PGP in browser, simple and secure." />
<meta name="keywords" content="browserPGP,PGP,OpenPGP,online,browser,javascript,github,live,secure,key generator,key gen,encrypt,decrypt,sign,verify,signature">
<meta name="author" content="ar0n#1462">
<link rel="icon" type='image/png' sizes='256x256' href="/256.png"/>
<link rel="stylesheet" href="bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="prngCheck.js"></script>
<script src="favicon.js"></script>
<script src="sha1.min.js"></script>
<script src="openpgp.min.js"></script>
<script src="jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
<script>
openpgp.initWorker({ path:'openpgp.worker.min.js' }) // set the relative web worker path
const encryptDecryptFunction = async() => {
document.getElementById("progressbar").className = "progress-bar progress-bar-striped progress-bar-animated";
// 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).catch((err) => {document.getElementById("result").value = err.message;document.getElementById("progressbar").className = "progress-bar bg-danger";})).keys, // for encryption
}
openpgp.encrypt(options).then(ciphertext => {
encrypted = ciphertext.data // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
document.getElementById("result").value = encrypted;
document.getElementById("progressbar").className = "progress-bar bg-success";
}).catch(function(error){
document.getElementById("result").value = error.message;
document.getElementById("progressbar").className = "progress-bar bg-danger";
});
}
</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="/">
<img src="/logo.svg" width="30" height="30" class="d-inline-block align-top" alt="">
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">
<a class="nav-link" href="/">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/gen.html">Key Generator</a>
</li>
<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="/sign.html">Sign</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/verify.html">Verify</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/compatibility.html">Compatibility</a>
</li>
</ul>
</div>
</nav>
<div class="main">
<div class="container-fluid">
<div class="row">
<div class="col-sm">
<div class="form-group">
<label for="exampleFormControlTextarea1">Public Key</label>
<textarea class="form-control" style="font-size: 10px;" rows="10" 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="Secret Message"></textarea>
</div>
<div class="form-group progress">
<div class="progress-bar" role="progressbar" id="progressbar" style="width: 100%"></div>
</div>
<button type="button" onclick="encryptDecryptFunction()" class="btn btn-primary">Encrypt</button>
</div>
<div class="col-sm">
<div class="form-group">
<label for="exampleFormControlTextarea1">PGP Output</label>
<textarea class="form-control" style="font-size: 10px;" rows="10" id="result" placeholder="-----BEGIN PGP MESSAGE-----" readonly></textarea>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<!-- BlnD=@3B2sFD,f++D5D0F<L -->