Browse Source

readme update

scitor 1 year ago
parent
commit
f4bcc0356d
Signed by: scitor (C4CB001A60CA5028)
3 changed files with 10 additions and 8 deletions
  1. 5
    2
      README.md
  2. 4
    5
      mm-aes.js
  3. 1
    1
      mm-aes.min.js

+ 5
- 2
README.md View File

@@ -3,12 +3,15 @@
3 3
 ## Bookmarklet
4 4
 
5 5
 You can copy and paste this into your address bar, while on your favorite mattermost chat:
6
-```
7
-var password="asdf";(function(){function a(a,f){var b=Object.assign({iv:new Uint8Array(16)},k);window.crypto.getRandomValues(b.iv);return window.crypto.subtle.encrypt(b,a,f).then(function(a){return new Uint8Array([].concat.call([].slice.call(b.iv),[].slice.call(new Uint8Array(a))))})}function c(a,f){var b=Object.assign({iv:new Uint8Array(16)},k);b.iv=new Uint8Array([].slice.call(f,0,16));return window.crypto.subtle.decrypt(b,a,new Uint8Array([].slice.call(f,16)))}function d(a){return Array.prototype.map.call(a,function(a){return String.fromCharCode(a)}).join("")}function e(a){var f=new Uint8Array(a.length);Array.prototype.map.call(a,function(a,c){f[c]=a.charCodeAt(0)});return f}function g(a){return encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,function(a,b){return String.fromCharCode(parseInt(b,16))})}function h(a){return decodeURIComponent(a.replace(/(.)/g,function(a,b){var c=b.charCodeAt(0).toString(16).toUpperCase();return"%"+(2>c.length?"0":"")+c}))}var l,k={name:"AES-CBC"};window.crypto.subtle.digest("SHA-256",e(g(password))).then(function(a){return window.crypto.subtle.importKey("raw",a,k,!1,["encrypt","decrypt"])}).then(function(a){l=a});(function f(){if(!document.getElementById("post_textbox"))return setTimeout(f,1E3);document.body.addEventListener("keydown",function(b){!b.ctrlKey||b.shiftKey||b.altKey||13!=b.keyCode||"post_textbox"!==b.target.id||(b.stopPropagation(),b.preventDefault(),a(l,e(g(b.target.value))).then(function(a){b.target.value="\ud83d\udd12"+btoa(d(a));b.target.dispatchEvent(new Event("input",{bubbles:!0}))}),b.target.value="crypting...")},!0)})();setInterval(function(){[].slice.call($('img[alt="\ud83d\udd12"]')).forEach(function(a){a.alt="\ud83d\udd13";var b=a.nextSibling.nodeValue;a.nextSibling.nodeValue="decrypting...";c(l,e(atob(b))).then(function(b){a.nextSibling.nodeValue=h(d(new Uint8Array(b)));a.parentNode.style.backgroundColor="#d0ffd0"})["catch"](function(b){console.log(b);a.nextSibling.nodeValue="";a.parentNode.style.backgroundColor="#ffd0d0"})})},1E3)})();
6
+```javascript
7
+var password="asdf";(function(){function a(a,f){var b=Object.assign({iv:new Uint8Array(16)},k);window.crypto.getRandomValues(b.iv);return window.crypto.subtle.encrypt(b,a,f).then(function(a){return new Uint8Array([].concat.call([].slice.call(b.iv),[].slice.call(new Uint8Array(a))))})}function c(a,f){var b=Object.assign({iv:new Uint8Array(16)},k);b.iv=new Uint8Array([].slice.call(f,0,16));return window.crypto.subtle.decrypt(b,a,new Uint8Array([].slice.call(f,16)))}function d(a){return Array.prototype.map.call(a,function(a){return String.fromCharCode(a)}).join("")}function e(a){var f=new Uint8Array(a.length);Array.prototype.map.call(a,function(a,c){f[c]=a.charCodeAt(0)});return f}function g(a){return encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,function(a,b){return String.fromCharCode(parseInt(b,16))})}function h(a){return decodeURIComponent(a.replace(/(.)/g,function(a,b){var c=b.charCodeAt(0).toString(16).toUpperCase();return"%"+(2>c.length?"0":"")+c}))}var l,k={name:"AES-CBC"};window.crypto.subtle.digest("SHA-256",e(g(password))).then(function(a){return window.crypto.subtle.importKey("raw",a,k,!1,["encrypt","decrypt"])}).then(function(a){l=a});(function f(){if(!document.getElementById("post_textbox"))return setTimeout(f,1E3);document.body.addEventListener("keydown",function(b){!b.ctrlKey||b.shiftKey||b.altKey||13!=b.keyCode||"post_textbox"!==b.target.id||(b.stopPropagation(),b.preventDefault(),a(l,e(g(b.target.value))).then(function(a){b.target.value="\ud83d\udd12"+btoa(d(a));b.target.dispatchEvent(new Event("input",{bubbles:!0}))}),b.target.value="encrypting...")},!0)})();setInterval(function(){[].slice.call($('img[alt="\ud83d\udd12"]')).forEach(function(a){a.alt="\ud83d\udd13";c(l,e(atob(a.nextSibling.nodeValue))).then(function(b){a.nextSibling.nodeValue=h(d(new Uint8Array(b)));a.parentNode.style.backgroundColor="#d0ffd0"})["catch"](function(b){console.log(b);a.nextSibling.nodeValue="";a.parentNode.style.backgroundColor="#ffd0d0"});a.nextSibling.nodeValue="decrypting..."})},1E3)})();
8 8
 ```
9 9
 Beware: When pasting Chrome removes the `javascript:` part as a _safety measure_... so don't forget to add it back.
10
+
10 11
 You can also make a bookmark with this ;)
11 12
 
13
+This uses the [mm-aes.min.js](./mm-aes.min.js), WebCrypto AES-CBC 256bit ([source](./mm-aes.js))
14
+
12 15
 ## Usage
13 16
 
14 17
 type message, `[CTRL]`+`[Enter]`, `[Enter]`

+ 4
- 5
mm-aes.js View File

@@ -34,16 +34,14 @@ var password = 'asdf';
34 34
 					event.target.value = '๐Ÿ”’' + bufferToBase64(cipher);
35 35
 					event.target.dispatchEvent(new Event('input', {bubbles: true}));
36 36
 				});
37
-			event.target.value = 'crypting...';
37
+			event.target.value = 'encrypting...';
38 38
 		}, true);
39 39
 	})();
40 40
 
41 41
 	setInterval(function decryptLocks() {
42
-		[].slice.call($(`img[alt="๐Ÿ”’"]`)).forEach(function (item) {
42
+		[].slice.call($('img[alt="๐Ÿ”’"]')).forEach(function (item) {
43 43
 			item.alt = '๐Ÿ”“';
44
-			var encrypted = item.nextSibling.nodeValue;
45
-			item.nextSibling.nodeValue = 'decrypting...';
46
-			decryptAES(key, base64ToBuffer(encrypted))
44
+			decryptAES(key, base64ToBuffer(item.nextSibling.nodeValue))
47 45
 				.then(function (text) {
48 46
 					item.nextSibling.nodeValue = bufferToUtf8(new Uint8Array(text));
49 47
 					item.parentNode.style.backgroundColor = '#d0ffd0';
@@ -53,6 +51,7 @@ var password = 'asdf';
53 51
 					item.nextSibling.nodeValue = '';
54 52
 					item.parentNode.style.backgroundColor = '#ffd0d0';
55 53
 				});
54
+			item.nextSibling.nodeValue = 'decrypting...';
56 55
 		});
57 56
 	}, 1000);
58 57
 

+ 1
- 1
mm-aes.min.js View File

@@ -1 +1 @@
1
-var password="asdf";(function(){function a(a,f){var b=Object.assign({iv:new Uint8Array(16)},k);window.crypto.getRandomValues(b.iv);return window.crypto.subtle.encrypt(b,a,f).then(function(a){return new Uint8Array([].concat.call([].slice.call(b.iv),[].slice.call(new Uint8Array(a))))})}function c(a,f){var b=Object.assign({iv:new Uint8Array(16)},k);b.iv=new Uint8Array([].slice.call(f,0,16));return window.crypto.subtle.decrypt(b,a,new Uint8Array([].slice.call(f,16)))}function d(a){return Array.prototype.map.call(a,function(a){return String.fromCharCode(a)}).join("")}function e(a){var f=new Uint8Array(a.length);Array.prototype.map.call(a,function(a,c){f[c]=a.charCodeAt(0)});return f}function g(a){return encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,function(a,b){return String.fromCharCode(parseInt(b,16))})}function h(a){return decodeURIComponent(a.replace(/(.)/g,function(a,b){var c=b.charCodeAt(0).toString(16).toUpperCase();return"%"+(2>c.length?"0":"")+c}))}var l,k={name:"AES-CBC"};window.crypto.subtle.digest("SHA-256",e(g(password))).then(function(a){return window.crypto.subtle.importKey("raw",a,k,!1,["encrypt","decrypt"])}).then(function(a){l=a});(function f(){if(!document.getElementById("post_textbox"))return setTimeout(f,1E3);document.body.addEventListener("keydown",function(b){!b.ctrlKey||b.shiftKey||b.altKey||13!=b.keyCode||"post_textbox"!==b.target.id||(b.stopPropagation(),b.preventDefault(),a(l,e(g(b.target.value))).then(function(a){b.target.value="\ud83d\udd12"+btoa(d(a));b.target.dispatchEvent(new Event("input",{bubbles:!0}))}),b.target.value="crypting...")},!0)})();setInterval(function(){[].slice.call($('img[alt="\ud83d\udd12"]')).forEach(function(a){a.alt="\ud83d\udd13";var b=a.nextSibling.nodeValue;a.nextSibling.nodeValue="decrypting...";c(l,e(atob(b))).then(function(b){a.nextSibling.nodeValue=h(d(new Uint8Array(b)));a.parentNode.style.backgroundColor="#d0ffd0"})["catch"](function(b){console.log(b);a.nextSibling.nodeValue="";a.parentNode.style.backgroundColor="#ffd0d0"})})},1E3)})();
1
+var password="asdf";(function(){function a(a,f){var b=Object.assign({iv:new Uint8Array(16)},k);window.crypto.getRandomValues(b.iv);return window.crypto.subtle.encrypt(b,a,f).then(function(a){return new Uint8Array([].concat.call([].slice.call(b.iv),[].slice.call(new Uint8Array(a))))})}function c(a,f){var b=Object.assign({iv:new Uint8Array(16)},k);b.iv=new Uint8Array([].slice.call(f,0,16));return window.crypto.subtle.decrypt(b,a,new Uint8Array([].slice.call(f,16)))}function d(a){return Array.prototype.map.call(a,function(a){return String.fromCharCode(a)}).join("")}function e(a){var f=new Uint8Array(a.length);Array.prototype.map.call(a,function(a,c){f[c]=a.charCodeAt(0)});return f}function g(a){return encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,function(a,b){return String.fromCharCode(parseInt(b,16))})}function h(a){return decodeURIComponent(a.replace(/(.)/g,function(a,b){var c=b.charCodeAt(0).toString(16).toUpperCase();return"%"+(2>c.length?"0":"")+c}))}var l,k={name:"AES-CBC"};window.crypto.subtle.digest("SHA-256",e(g(password))).then(function(a){return window.crypto.subtle.importKey("raw",a,k,!1,["encrypt","decrypt"])}).then(function(a){l=a});(function f(){if(!document.getElementById("post_textbox"))return setTimeout(f,1E3);document.body.addEventListener("keydown",function(b){!b.ctrlKey||b.shiftKey||b.altKey||13!=b.keyCode||"post_textbox"!==b.target.id||(b.stopPropagation(),b.preventDefault(),a(l,e(g(b.target.value))).then(function(a){b.target.value="\ud83d\udd12"+btoa(d(a));b.target.dispatchEvent(new Event("input",{bubbles:!0}))}),b.target.value="encrypting...")},!0)})();setInterval(function(){[].slice.call($('img[alt="\ud83d\udd12"]')).forEach(function(a){a.alt="\ud83d\udd13";c(l,e(atob(a.nextSibling.nodeValue))).then(function(b){a.nextSibling.nodeValue=h(d(new Uint8Array(b)));a.parentNode.style.backgroundColor="#d0ffd0"})["catch"](function(b){console.log(b);a.nextSibling.nodeValue="";a.parentNode.style.backgroundColor="#ffd0d0"});a.nextSibling.nodeValue="decrypting..."})},1E3)})();