This repository has been archived by the owner on Oct 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
60 lines (54 loc) · 2.28 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>AWS S3 URL Signer</title>
<script src="js/jquery-1.11.2.min.js"></script>
<link rel="stylesheet" type="text/css" href="js/datetimepicker/jquery.datetimepicker.css">
<script src="js/datetimepicker/jquery.datetimepicker.js"></script>
<script src="js/sha1.js"></script>
<script>
function hmacsha1(data, key) {
return new jsSHA(data, 'TEXT').getHMAC(key, 'TEXT', 'SHA-1', 'B64');
}
function sign(expires, key, bucket, path) {
return hmacsha1('GET\n\n\n' + expires + '\n/' + bucket + '/' + path, key);
}
function signedUrl(expires, bucket, path, accesskey, secret) {
var signature = sign(expires, secret, bucket, path);
return 'https://' + bucket + '.s3.amazonaws.com/' + path + '?AWSAccessKeyId=' + accesskey + '&Expires='
+ expires + '&Signature=' + encodeURIComponent(signature);
}
function computesha() {
var expires = $('#expires').val();
var bucket = $('#bucket').val();
var path = $('#path').val();
var accesskey = $('#accesskey').val();
var secret = $('#secret').val();
$('#output').val(signedUrl(expires, bucket, path, accesskey, secret));
}
$(document).ready(function() {
$('#expires').datetimepicker({format: 'unixtime', step: 1, onChangeDateTime: computesha});
$('input').on('input', function() {
computesha();
})
});
</script>
<style>
input[type=text] { width: 500px; }
</style>
</head>
<body>
<h1>AWS S3 URL Signer</h1>
<p>The implementation is fully Javascript, so no details will be sent to a server.</p>
<table>
<tr><td>Expires:</td><td><input type="text" id="expires"></td></tr>
<tr><td>Bucket:</td><td><input type="text" id="bucket"></td></tr>
<tr><td>Path:</td><td><input type="text" id="path"></td></tr>
<tr><td>Access key:</td><td><input type="text" id="accesskey"></td></tr>
<tr><td>Secret:</td><td><input type="text" id="secret"></td></tr>
<tr><td><input type="button" onclick="computesha()" value="Sign"/></td></tr>
<tr><td>URL:</td><td><input type="text" id="output"></td></tr>
</table>
</body>
</html>