-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
92 lines (87 loc) · 3.42 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
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
<html>
<head>
<title>Simple online base64 encode/decode</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.0/css/bulma.min.css" />
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script>
<style>
.column {
padding-bottom: 0;
}
</style>
</head>
<body>
<div id="app" class="container">
<br/>
<h1 class="title">Simple online base64 encode/decode</h1>
<br/>
<div class="columns">
<h2 class="column is-half subtitle">Plain text</h2>
<div class="column has-text-right">
<span class="select">
<select v-model="passwordLength">
<option value="8">Length 8</option>
<option value="12">Length 12</option>
<option value="16">Length 16</option>
<option value="20">Length 20</option>
<option value="24">Length 24</option>
</select>
</span>
<button class="button" v-on:click="genPassword">Generate Password</button>
<button class="button clip-btn" data-clipboard-target="#text">Copy to Clipboard</button>
</div>
</div>
<textarea id="text" class="textarea" v-model="text" v-on:keyup="encode" v-on:change="encode"></textarea>
<br/>
<br/>
<div class="columns">
<h2 class="column is-half subtitle">Base64 encoded</h2>
<div class="column has-text-right">
<button class="button clip-btn" data-clipboard-target="#base64">Copy to Clipboard</button>
</div>
</div>
<textarea id="base64" class="textarea" v-model="base64" v-on:keyup="decode"></textarea>
<br/>
<p class="notification has-text-grey">
Type your text and get base64 encoded, or type your base64 and get the plain text.
<b>It's two way binded!</b>
</p>
<hr/>
<p class="has-text-centered">
With ♥ by
<a target="blank" href="https://www.enbiso.com">enbiso</a> |
<a target="blank" href="https://github.com/enbiso/online-base64">Fork in Github</a>
</p>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
text: '',
base64: '',
passwordLength: 16
},
methods: {
encode: function (event) {
this.$data.base64 = btoa(this.$data.text);
},
decode: function (event) {
this.$data.text = atob(this.$data.base64);
},
genPassword: function (event) {
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let text = "";
for (let i = 0; i < this.$data.passwordLength; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
this.$data.text = text;
this.encode(event);
}
}
});
new ClipboardJS('.clip-btn');
</script>
</body>
</html>