-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
62 lines (48 loc) · 2.51 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Encrypt message online</title>
<meta name="description" content="Encrypt your message in-browser and download it in a pdf file">
<script type="text/javascript" src="./pdfkit.js"></script>
<script type="text/javascript" src="./blob-stream.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.min.js"></script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body>
<a class="github-button" href="https://github.com/petrgazarov/message-encrypt" data-size="large" data-show-count="true" aria-label="View petrgazarov/message-encrypt on GitHub">View on Github</a>
<h1>Message encrypt</h1>
<h2>Encrypts your message using AES 256 bit encryption and saves it in a PDF file. Work done 100% in the browser.</h2>
<h3>Powered by pdfkit JavaScript library</h3>
<form onsubmit="return encryptPDF()">
<label for="file-name-input">File name</label>
<input type="text" id="file-name-input"/>
<label for='file-text-input'>Enter your message</label>
<textarea id='file-text-input'></textarea>
<label for='password-input'>Enter your password</label>
<input id='password-input' type='password'></textarea>
<button type='submit'>Save PDF</button>
</form>
<p>
This page generates PDF document version 1.7 and uses AES 256 bit encryption. The PDF document is generated entirely in-browser using JavaScript.
PDF documents generated on this site can be opened by conventional software such as browsers, MacOS Preview and Adobe Acrobat Reader.
Most sites require you to upload a pdf file to their servers for encryption, which requires trust in the 3rd party provider.
This site removes the need for trust by doing all work 100% in the browser, using JavaScript.
</p>
</body>
<script>
const encryptPDF = function() {
const fileName = document.getElementById('file-name-input').value;
const fileContents = document.getElementById('file-text-input').value;
const userPassword = document.getElementById('password-input').value;
const pdf = new PDFDocument({ pdfVersion: '1.7ext3', userPassword: userPassword });
const stream = pdf.pipe(blobStream());
pdf.text(fileContents);
pdf.end();
stream.on('finish', function() {
blob = stream.toBlob('application/pdf');
saveAs(blob, fileName);
});
}
</script>
</html>