From 6cfd005c9857162610e017ec66851df1f2051caa Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Mon, 21 May 2012 11:15:12 +0200 Subject: [PATCH 01/11] Fix typo on
--- zerobin/views/base.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zerobin/views/base.tpl b/zerobin/views/base.tpl index cb1f724..17a6b0e 100644 --- a/zerobin/views/base.tpl +++ b/zerobin/views/base.tpl @@ -133,7 +133,7 @@ --> -
+

Based on an original idea from sebsauvage.net
From e83a7d6a58b2281e10d62ae1c5741a27356d4334 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 21 May 2012 13:16:49 +0200 Subject: [PATCH 02/11] Added a FAQ --- zerobin/static/css/style.css | 8 ++++ zerobin/static/css/style.min.css | 2 +- zerobin/views/faq.tpl | 69 ++++++++++++++++++++++---------- 3 files changed, 57 insertions(+), 22 deletions(-) diff --git a/zerobin/static/css/style.css b/zerobin/static/css/style.css index 90c7abe..83c847c 100644 --- a/zerobin/static/css/style.css +++ b/zerobin/static/css/style.css @@ -348,3 +348,11 @@ canvas { color: red; font-weight: bold; } + +#faq dt { + margin:2em 0 1em 0; +} + +#faq p { + margin:1em; +} \ No newline at end of file diff --git a/zerobin/static/css/style.min.css b/zerobin/static/css/style.min.css index 7ff60ec..ad5df11 100644 --- a/zerobin/static/css/style.min.css +++ b/zerobin/static/css/style.min.css @@ -4,4 +4,4 @@ article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display /* Prettify */ .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} /* Custom */ -.brand{font-size:38px!important;padding:0 55px 3px!important;text-shadow:0 1px 0 rgba(255,255,255,.1),0 0 30px rgba(255,255,255,.125);-webkit-transition:all .2s linear;-moz-transition:all .2s linear;transition:all .2s linear}.brand span{font-size:48px;line-height:0}.brand em{display:inline;color:#d40202;margin:0!important;font-size:27px}.about{line-height:13px;font-style:italic;text-align:right;padding-top:9px;margin-bottom:0!important}.about span{font-size:10px}body{padding-top:60px;padding-bottom:40px}.sidebar-nav{padding:9px 0}select{width:135px}label{display:inline;margin-left:18px;font-style:italic;font-size:11px;color:#888}ul,ol{padding:0;margin:0}li{margin-left:-9px}p{margin:0 0 20px}.grey{color:#999}.nav-list{padding-right:0!important;font-size:12px}blockquote{width:630px;float:left}h4 p{float:left;font-size:80px;text-shadow:1px 3px 1px #DDD,0 0 4px #333;-webkit-transition:all .2s linear;-moz-transition:all .2s linear;transition:all .2s linear;margin-right:7px;margin-top:3px}h4#pixels-total{position:relative;width:166px;float:right;margin:8px 0 0 0;padding:0 0 0 54px;font-size:1.1em;line-height:1.4;font-weight:normal;color:#777;-webkit-border-top-right-radius:6px;-webkit-border-top-left-radius:20px;-moz-border-top-right-radius:6px;-moz-border-top-left-radius:20px;border-top-right-radius:6px;border-top-left-radius:20px}.greetings{clear:both;margin:0 auto;text-align:center;margin-top:40px}.alert .title{display:block}.btn-group{float:left}html.file-upload p.file-upload{float:left;margin:22px 0 0 21px;display:none}html.file-upload p.file-upload{display:inherit}html.no-file-upload p.file-upload{display:none}input.btn-upload{position:relative;left:-6px;width:100px;z-index:1;margin-top:-13px}input.hide-upload{position:relative;left:-110px;-moz-opacity:0;filter:alpha(opacity:0);opacity:0;z-index:2;width:100px;margin-top:-20px;cursor:pointer;cursor:hand;height:49px}#paste-content{background-color:white;padding:1em}#paste-content.done{background-color:white;padding-top:1em;padding-left:0}.submit-form{display:none}.paste-option{float:right}a#clip-button.hover{cursor:pointer;text-decoration:underline}li.L0,li.L1,li.L2,li.L3,li.L4,li.L5,li.L6,li.L7,li.L8,li.L9{list-style-type:decimal;background:inherit}.prettyprint.linenums{-webkit-box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0;-moz-box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0;box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0}ol.linenums{margin:0 0 0 55px}ol.linenums li{color:#bebec5;line-height:18px;text-shadow:0 1px 0 #fff}.prettyprint{padding:8px;background-color:#f7f7f9;border:1px solid #e1e1e8}pre{font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,monospace,serif;line-height:21px;font-size:12px}.kwd{color:#66F}.pun,.opn,.clo{color:#0A0}.lit{color:#933}.com{color:#C0C}form{padding-bottom:3em!important;padding-right:17px}form textarea{overflow-y:auto}button.btn,input[type="submit"].btn{margin-left:5px}.well{padding-bottom:40px;padding-right:17px}.legal{margin:0 auto;width:300px;text-align:center;margin-top:30px}.btn{margin-left:5px}.btn-primary,.btn-danger{position:relative;top:-4px}#alert-template{display:none}.progress{display:none}.progress .bar{width:25%;text-indent:10px;text-align:left}.lnk-option canvas{vertical-align:middle;margin-right:10px}.previous-pastes .item{margin-top:5px;vertical-align:middle;line-height:24px;padding-left:1em}li.item{margin-left:-13px;margin-right:-5px}.previous-pastes canvas{display:block;float:left;margin-right:5px}html.local-storage .no-local-storage{display:none}html.no-local-storage .local-storage{display:none}canvas{border:1px solid white}#wrap-content{display:none}.noscript{text-align:center;color:red;font-weight:bold} \ No newline at end of file +.brand{font-size:38px!important;padding:0 55px 3px!important;text-shadow:0 1px 0 rgba(255,255,255,.1),0 0 30px rgba(255,255,255,.125);-webkit-transition:all .2s linear;-moz-transition:all .2s linear;transition:all .2s linear}.brand span{font-size:48px;line-height:0}.brand em{display:inline;color:#d40202;margin:0!important;font-size:27px}.about{line-height:13px;font-style:italic;text-align:right;padding-top:9px;margin-bottom:0!important}.about span{font-size:10px}body{padding-top:60px;padding-bottom:40px}.sidebar-nav{padding:9px 0}select{width:135px}label{display:inline;margin-left:18px;font-style:italic;font-size:11px;color:#888}ul,ol{padding:0;margin:0}li{margin-left:-9px}p{margin:0 0 20px}.grey{color:#999}.nav-list{padding-right:0!important;font-size:12px}blockquote{width:630px;float:left}h4 p{float:left;font-size:80px;text-shadow:1px 3px 1px #DDD,0 0 4px #333;-webkit-transition:all .2s linear;-moz-transition:all .2s linear;transition:all .2s linear;margin-right:7px;margin-top:3px}h4#pixels-total{position:relative;width:166px;float:right;margin:8px 0 0 0;padding:0 0 0 54px;font-size:1.1em;line-height:1.4;font-weight:normal;color:#777;-webkit-border-top-right-radius:6px;-webkit-border-top-left-radius:20px;-moz-border-top-right-radius:6px;-moz-border-top-left-radius:20px;border-top-right-radius:6px;border-top-left-radius:20px}.greetings{clear:both;margin:0 auto;text-align:center;margin-top:40px}.alert .title{display:block}.btn-group{float:left}html.file-upload p.file-upload{float:left;margin:22px 0 0 21px;display:none}html.file-upload p.file-upload{display:inherit}html.no-file-upload p.file-upload{display:none}input.btn-upload{position:relative;left:-6px;width:100px;z-index:1;margin-top:-13px}input.hide-upload{position:relative;left:-110px;-moz-opacity:0;filter:alpha(opacity:0);opacity:0;z-index:2;width:100px;margin-top:-20px;cursor:pointer;cursor:hand;height:49px}#paste-content{background-color:white;padding:1em}#paste-content.done{background-color:white;padding-top:1em;padding-left:0}.submit-form{display:none}.paste-option{float:right}a#clip-button.hover{cursor:pointer;text-decoration:underline}li.L0,li.L1,li.L2,li.L3,li.L4,li.L5,li.L6,li.L7,li.L8,li.L9{list-style-type:decimal;background:inherit}.prettyprint.linenums{-webkit-box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0;-moz-box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0;box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0}ol.linenums{margin:0 0 0 55px}ol.linenums li{color:#bebec5;line-height:18px;text-shadow:0 1px 0 #fff}.prettyprint{padding:8px;background-color:#f7f7f9;border:1px solid #e1e1e8}pre{font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,monospace,serif;line-height:21px;font-size:12px}.kwd{color:#66F}.pun,.opn,.clo{color:#0A0}.lit{color:#933}.com{color:#C0C}form{padding-bottom:3em!important;padding-right:17px}form textarea{overflow-y:auto}button.btn,input[type="submit"].btn{margin-left:5px}.well{padding-bottom:40px;padding-right:17px}.legal{margin:0 auto;width:300px;text-align:center;margin-top:30px}.btn{margin-left:5px}.btn-primary,.btn-danger{position:relative;top:-4px}#alert-template{display:none}.progress{display:none}.progress .bar{width:25%;text-indent:10px;text-align:left}.lnk-option canvas{vertical-align:middle;margin-right:10px}.previous-pastes .item{margin-top:5px;vertical-align:middle;line-height:24px;padding-left:1em}li.item{margin-left:-13px;margin-right:-5px}.previous-pastes canvas{display:block;float:left;margin-right:5px}html.local-storage .no-local-storage{display:none}html.no-local-storage .local-storage{display:none}canvas{border:1px solid white}#wrap-content{display:none}.noscript{text-align:center;color:red;font-weight:bold}#faq dt{margin:2em 0 1em 0}#faq p{margin:1em} \ No newline at end of file diff --git a/zerobin/views/faq.tpl b/zerobin/views/faq.tpl index a8121d2..053fdbd 100644 --- a/zerobin/views/faq.tpl +++ b/zerobin/views/faq.tpl @@ -1,31 +1,58 @@ -

+

FAQ

- - %for i, entry in enumerate(settings.MENU): - %if "mailto:" in entry[1]: -

If a question does not appear here you can - . -

- %end - %end
-
What's the name of the captain?
-
The name of the captain is Igloo !
-
-
What's the name of the captain?
-
The name of the captain is Igloo !
-
-
What's the name of the captain?
-
The name of the captain is Igloo !
- +
How does it work?
+
+

We generate a random key, and encrypt the paste with it using + the sjcl javascript library.

+

The content is sent encrypted to the server, which returns the + address of the paste.

+

The javascript code take the address, and add the encryption + key in the URL hash (#).

+

When somebody reads the paste, he goes to the URL. If + the hash with the key is in it, the javascript will use it + to decrypt the content sent by the server.

+

The browser never sends the hash to the server, so it does not + receives the key.

+
+ +
Javascript encryption is not secure!
+
+

No it's not.

+

The goal of 0bin is not to protect the users + or their secrets.

+

The goal is to make it hard to sue the host because of the + content users pasted in his service. The idea is that you can not + require somebody to moderate something he can't read

+
+
What if the server change the Javascript? Or in the case of a man + in the middle attack?
+
+

Read above.

+

0bin the is not built to protect the users content. It is built to + protect the host. If the user content is compromised, 0bin still + provides the host with the main feature: ignorance of the hosted content.

+

The case where the host himself compromise the encryption process + to read the content makes no sense: in that case he wouldn't have + installed 0bin in the first place. 0bin is here to protect him.

+

If you want to be sure nobody can read your content, you should + not use 0bin. Use + cryptocat (but JS crypto warnings apply) + or OTR for chatting, + GPG/enignmail + for emails and TrueCrypt for storage.

+
+
How did you come out with such a cool idea?
+
+

We didn't, we based 0bin on + sebsauvage's work.

+
+
From c96e8b60063ed140f4299cbd3563ed9531cefb89 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 21 May 2012 13:21:16 +0200 Subject: [PATCH 03/11] Typo --- zerobin/views/base.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zerobin/views/base.tpl b/zerobin/views/base.tpl index d839baf..cb1f724 100644 --- a/zerobin/views/base.tpl +++ b/zerobin/views/base.tpl @@ -126,12 +126,12 @@ Edgar Allan Poe - - - + + -->

From fb60e4e332d9b005d6c156c325a3788c769f5363 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 21 May 2012 13:38:53 +0200 Subject: [PATCH 04/11] Added pastebin article to FAQ --- zerobin/views/faq.tpl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zerobin/views/faq.tpl b/zerobin/views/faq.tpl index 053fdbd..733396e 100644 --- a/zerobin/views/faq.tpl +++ b/zerobin/views/faq.tpl @@ -51,6 +51,14 @@

We didn't, we based 0bin on sebsauvage's work.

+ +

It was a reaction to + Pastebin been forced to moderate its content + because of so many illegal stuffed posted to it. 0bin should be used the + same way Pastebin is for users. The only + difference is that if you host it, we hope the encryption + feature can be used as a defense. This is not proven though :-)

+
From 111255352c095012c794ccad3800743da0ef02e1 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 21 May 2012 18:01:52 +0200 Subject: [PATCH 05/11] Improved FAQ --- zerobin/views/faq.tpl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/zerobin/views/faq.tpl b/zerobin/views/faq.tpl index 733396e..c6b13f2 100644 --- a/zerobin/views/faq.tpl +++ b/zerobin/views/faq.tpl @@ -9,14 +9,15 @@
How does it work?

We generate a random key, and encrypt the paste with it using - the sjcl javascript library.

+ the sjcl + javascript library.

The content is sent encrypted to the server, which returns the - address of the paste.

-

The javascript code take the address, and add the encryption - key in the URL hash (#).

-

When somebody reads the paste, he goes to the URL. If - the hash with the key is in it, the javascript will use it - to decrypt the content sent by the server.

+ address of the newly created paste.

+

The javascript code then redirects to this address, but it adds the + encryption key in the URL hash (#).

+

When somebody want to read the paste, he usually just click on a link + with this URL. If the hash containing the key is part of it, Obin's + javascript will use it to decrypt the content sent by the server.

The browser never sends the hash to the server, so it does not receives the key.

From f9e4f4acc0731bd7aee6784e8f5ee236a7f2adff Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 21 May 2012 18:06:50 +0200 Subject: [PATCH 06/11] Typo --- zerobin/views/faq.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zerobin/views/faq.tpl b/zerobin/views/faq.tpl index c6b13f2..5476336 100644 --- a/zerobin/views/faq.tpl +++ b/zerobin/views/faq.tpl @@ -31,14 +31,14 @@ content users pasted in his service. The idea is that you can not require somebody to moderate something he can't read

-
What if the server change the Javascript? Or in the case of a man +
What if the server changes the Javascript code? Or in the case of a man in the middle attack?

Read above.

0bin the is not built to protect the users content. It is built to protect the host. If the user content is compromised, 0bin still provides the host with the main feature: ignorance of the hosted content.

-

The case where the host himself compromise the encryption process +

The case where the host himself compromises the encryption process to read the content makes no sense: in that case he wouldn't have installed 0bin in the first place. 0bin is here to protect him.

If you want to be sure nobody can read your content, you should From 8cb545746706d919ea711f824df8fe805ea21714 Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Mon, 21 May 2012 11:13:19 +0200 Subject: [PATCH 07/11] Add wrap-content end tag. --- zerobin/views/base.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/zerobin/views/base.tpl b/zerobin/views/base.tpl index cb1f724..1bd1be8 100644 --- a/zerobin/views/base.tpl +++ b/zerobin/views/base.tpl @@ -155,6 +155,7 @@

+
From 7703b26333f7ff639aa07d66af6b998bee8ac00f Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 22 May 2012 12:45:44 +0200 Subject: [PATCH 08/11] Improved url sanitizing --- zerobin/static/js/behavior.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zerobin/static/js/behavior.js b/zerobin/static/js/behavior.js index df3b84f..6cac288 100644 --- a/zerobin/static/js/behavior.js +++ b/zerobin/static/js/behavior.js @@ -269,12 +269,12 @@ window.zerobin = { getPasteId: function(url){ var loc = url ? zerobin.parseUrl(url) : window.location; - return loc.pathname.replace(/\/|paste/g, '').replace(/\?.*$/, ''); + return loc.pathname.replace(/\/|paste/g, ''); }, getPasteKey: function(url){ var loc = url ? zerobin.parseUrl(url) : window.location; - return loc.hash.replace('#', '').replace(/\?.*$/, ''); + return loc.hash.replace('#', '').replace(/(\?|&).*$/, ''); }, /** Return the paste content stripted from any code coloration */ From dc4e482bb2d655b63ad8f2ddd40ab6e13b283dc2 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 22 May 2012 12:49:12 +0200 Subject: [PATCH 09/11] Added licence to readme --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 50423bc..cb26477 100644 --- a/README.rst +++ b/README.rst @@ -11,7 +11,7 @@ be pasted in it. The idea is that one can (probably...) not be legally entitled to `moderate the pastebin content`_ as he/she has no way to decrypt it. It's an Python implementation of the -`zerobin project`_. It's easy to +`zerobin project`_ under the `WTF licence`_. It's easy to install even if you know nothing about Python. For now tested with IE9, and the last opera, safari, chrome and FF. @@ -96,4 +96,5 @@ What does 0bin not implement? .. _Bootstrap: http://twitter.github.com/bootstrap/ .. _VizHash.js: https://github.com/sametmax/VizHash.js .. _Cherrypy: http://www.cherrypy.org/ (server only) -.. _is not worth it: http://stackoverflow.com/questions/201705/how-many-random-elements-before-md5-produces-collisions \ No newline at end of file +.. _is not worth it: http://stackoverflow.com/questions/201705/how-many-random-elements-before-md5-produces-collisions +.. _WTF licence: http://en.wikipedia.org/wiki/WTFPL \ No newline at end of file From 22774feb8f1d184436092e2cfe1d30e3e8179f1f Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 22 May 2012 13:40:17 +0200 Subject: [PATCH 10/11] Changed short url provider --- zerobin/static/js/behavior.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zerobin/static/js/behavior.js b/zerobin/static/js/behavior.js index 6cac288..03e654c 100644 --- a/zerobin/static/js/behavior.js +++ b/zerobin/static/js/behavior.js @@ -177,9 +177,9 @@ window.zerobin = { /** Get a tinyurl using JSONP */ getTinyURL: function(longURL, success) { - var api = 'http://json-tinyurl.appspot.com/?url='; + var api = 'http://is.gd/create.php?format=json&url='; $.getJSON(api + encodeURIComponent(longURL) + '&callback=?', function(data){ - success(data.tinyurl); + success(data.shorturl); }); }, From 2b9a70c19b099b0c397ae0249e4f2b28a999f333 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 22 May 2012 13:40:58 +0200 Subject: [PATCH 11/11] Recompressed static --- zerobin/static/js/main.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zerobin/static/js/main.min.js b/zerobin/static/js/main.min.js index 9533d04..b6447f6 100644 --- a/zerobin/static/js/main.min.js +++ b/zerobin/static/js/main.min.js @@ -48,4 +48,4 @@ b[d[2]]=d[3]?parseInt(d[3],10):d[2].match(/^(ct|salt|iv)$/)?sjcl.codec.base64.to undefined)c[b[d]]=a[b[d]];return c}};sjcl.encrypt=sjcl.json.encrypt;sjcl.decrypt=sjcl.json.decrypt;sjcl.misc.S={};sjcl.misc.cachedPbkdf2=function(a,b){var c=sjcl.misc.S,d;b=b||{};d=b.iter||1E3;c=c[a]=c[a]||{};d=c[d]=c[d]||{firstSalt:b.salt&&b.salt.length?b.salt.slice(0):sjcl.random.randomWords(2,0)};c=b.salt===undefined?d.firstSalt:b.salt;d[c]=d[c]||sjcl.misc.pbkdf2(a,c,b.iter);return{key:d[c].slice(0),salt:c.slice(0)}}; /* custom */ -(function(){sjcl.random.startCollectors();$.ajaxSetup({cache:true});function a(c){var b=arguments;return function(){return c.apply(c,Array.prototype.slice.call(b,1))}}window.zerobin={version:"0.1",encrypt:function(f,g,d,b,e,c){setTimeout(function(){g=sjcl.codec.utf8String.toBits(g);if(d){d()}setTimeout(function(){g=sjcl.codec.base64.fromBits(g);if(b){b()}setTimeout(function(){g=lzw.compress(g);if(e){e()}setTimeout(function(){g=sjcl.encrypt(f,g);if(c){c(g)}},250)},250)},250)},250)},decrypt:function(f,g,d,b,e,h,c){setTimeout(function(){try{g=sjcl.decrypt(f,g);if(b){b()}setTimeout(function(){try{g=lzw.decompress(g);if(e){e()}setTimeout(function(){try{g=sjcl.codec.base64.toBits(g);if(h){h()}setTimeout(function(){try{g=sjcl.codec.utf8String.fromBits(g);if(c){c(g)}}catch(l){d(l)}},250)}catch(k){d(k)}},250)}catch(j){d(j)}},250)}catch(i){d(i)}},250)},makeKey:function(){return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8,0),0)},getFormatedDate:function(b){b=b||new Date();return((b.getMonth()+1)+"-"+b.getDate()+"-"+b.getFullYear())},getFormatedTime:function(c){c=c||new Date();var e=c.getHours();var b=c.getMinutes();var d=c.getSeconds();if(e<10){e="0"+e}if(b<10){b="0"+b}if(d<10){d="0"+d}return e+":"+b+":"+d},numOrdA:function(d,c){return(d-c)},getLocalStorageKeys:function(b){b="zerobinV"+(b||zerobin.version);var d=[];for(var c in localStorage){if(c.indexOf(b)!==-1){d.push(c)}}d.sort();d.reverse();return d},getTinyURL:function(d,c){var b="http://json-tinyurl.appspot.com/?url=";$.getJSON(b+encodeURIComponent(d)+"&callback=?",function(e){c(e.tinyurl)})},support:{localStorage:(function(){var b=!!(localStorage);$("html").addClass((b?"":"no-")+"local-storage");return b})(),history:(function(){var b=!!(window.history&&history.pushState);$("html").addClass((b?"":"no-")+"history");return b})(),fileUpload:(function(){var b=window;var c=!!(b.File&&b.FileReader&&b.FileList&&b.Blob);$("html").addClass((c?"":"no-")+"file-upload");return c})()},storePaste:function(c,b){b=b||new Date();b=(b.getFullYear()+"-"+(b.getMonth()+1)+"-"+b.getDate()+" "+zerobin.getFormatedTime(b));var d=zerobin.getLocalStorageKeys();if(localStorage.length>19){void localStorage.removeItem(d[19])}localStorage.setItem("zerobinV"+zerobin.version+"#"+b,c)},getPreviousPastes:function(){var c=[],d=zerobin.getLocalStorageKeys(),b=zerobin.getFormatedDate();$.each(d,function(g,f){var j=f.replace(/^[^#]+#/,"");var e=j.match(/^(\d+)-(\d+)-(\d+)\s/);e=e[2]+"-"+e[3]+"-"+e[1];var h="the ";if(e===b){e=j.split(" ")[1];h="at "}c.push({displayDate:e,prefix:h,link:localStorage.getItem(f)})});return c},parseUrl:(function(){var b=document.createElement("div");b.innerHTML="";return function(c){b.firstChild.href=c;b.innerHTML=b.innerHTML;return b.firstChild}})(),getPasteId:function(b){var c=b?zerobin.parseUrl(b):window.location;return c.pathname.replace(/\/|paste/g,"").replace(/\?.*$/,"")},getPasteKey:function(b){var c=b?zerobin.parseUrl(b):window.location;return c.hash.replace("#","").replace(/\?.*$/,"")},getPasteContent:function(){var b="";$("#paste-content li").each(function(c){b=b+$(this).text()+"\n"});return b},count:function(h,d){var g=/(\r?\n|\r)/g;var c=/(\r?\n|\r|\s+)/g;d=d||{};d.lineBreaks=d.lineBreaks||1;var f=h.length,e=f-h.replace(/[\u0100-\uFFFF]/g,"").length,b=f-h.replace(g,"").length;return f+e+Math.max(0,d.lineBreaks*(b-1))},message:function(d,e,f,b,g){$(window).scrollTop(0);if(b){$(".alert-"+d).remove()}var c=$("#alert-template").clone().attr("id",null).addClass("alert alert-"+d);$(".message",c).html(e);if(f){$(".title",c).html(f)}else{$(".title",c).remove()}c.prependTo($("#main")).show("fadeUp",g)},progressBar:function(b){var d=$(b);var c={container:d,elem:d.find(".bar")};c.set=function(f,e){c.elem.text(f).css("width",e)};return c}};$(function(){$(".btn-primary").live("click",function(s){s.preventDefault();var p=$("textarea").val();var n=zerobin.count($("#content").val());var o=n>zerobin.max_size;var r=Math.round(n/1024);var u=Math.round(zerobin.max_size/1024);if(o){zerobin.message("error",('Your file is '+r+"KB. You have reached the maximum size limit of "+u+"KB."),"Warning!",true)}if(!o&&p.trim()){var x=$("input, textarea, select, button").prop("disabled",true);var t=zerobin.progressBar("form.well .progress");t.container.show();t.set("Converting paste to bits...","25%");try{var w=$("#expiration").val();var v=zerobin.makeKey();zerobin.encrypt(v,p,a(t.set,"Encoding to base64...","45%"),a(t.set,"Compressing...","65%"),a(t.set,"Encrypting...","85%"),function(e){t.set("Sending...","95%");var y={content:e,expiration:w};$.post("/paste/create",y).error(function(z){x.prop("disabled",false);t.container.hide();zerobin.message("error","Paste could not be saved. Please try again later.","Error")}).success(function(A){t.set("Redirecting to new paste...","100%");if(A.status==="error"){zerobin.message("error",A.message,"Error");x.prop("disabled",false);t.container.hide()}else{var z="/paste/"+A.paste+"#"+v;if(zerobin.support.localStorage){zerobin.storePaste(z)}window.location=(z)}})})}catch(q){x.prop("disabled",false);t.container.hide();zerobin.message("error","Paste could not be encrypted. Aborting.","Error")}}});var f=$("#paste-content").text().trim();var i=zerobin.getPasteKey();var h=false;if(f&&i){$.getScript("/static/js/vizhash.min.js").done(function(n,o){if(vizhash.supportCanvas){var e=vizhash.canvasHash(zerobin.getPasteId(),24,24);$('').click(function(p){p.preventDefault();if(confirm("This picture is unique to your paste so you can identify it quickly. \n\n Do you want to know more about this?")){window.open("http://is.gd/IJaMRG","_blank")}}).prependTo(".lnk-option").append(e.canvas)}});var l=$("input, textarea, select, button").prop("disabled",true);var g=zerobin.progressBar(".well form .progress");g.container.show();g.set("Decrypting paste...","25%");zerobin.decrypt(i,f,function(){g.container.hide();zerobin.message("error","Could not decrypt data (Wrong key ?)","Error")},a(g.set,"Decompressing...","45%"),a(g.set,"Base64 decoding...","65%"),a(g.set,"From bits to string...","85%"),function(e){$("#paste-content").text(e);e="";g.set("Code coloration...","95%");setTimeout(function(){ZeroClipboard.setMoviePath("/static/js/ZeroClipboard.swf");var o=new ZeroClipboard.Client();var n=function(){o.reposition()};o.addEventListener("mouseup",function(){$("#clip-button").text("Copying paste...");o.setText(zerobin.getPasteContent())});o.addEventListener("complete",function(){$("#clip-button").text("Copy to clipboard");zerobin.message("info","The paste is now in your clipboard","",true,n)});o.glue("clip-button");window.onresize=n;$("#short-url").click(function(p){p.preventDefault();$("#short-url").text("Loading short url...");zerobin.getTinyURL(window.location.toString(),function(q){o.setText(q);$("#copy-success").hide();zerobin.message("success",''+q+"","Short url",true,n);$("#short-url").text("Get short url")})});$(".close").off().live("click",function(p){p.preventDefault();$(this).parent().fadeOut(n)});prettyPrint();$("#paste-content").addClass("done");g.set("Done","100%");g.container.hide();l.prop("disabled",false)},250)})}$(".paste-option select").live("change",function(){$(".paste-option select").val($(this).val())});$("#content").elastic();$("#content").live("keyup change",function(){if($("#content").height()<400){$(".paste-option.down").remove()}else{if($(".paste-option").length===1){$(".paste-option").clone().addClass("down").appendTo("form.well")}}});if(zerobin.support.localStorage){var j=$(".previous-pastes"),m=zerobin.getPreviousPastes();if(m.length){$.getScript("/static/js/vizhash.min.js").done(function(e,n){j.find(".item").remove();$.each(zerobin.getPreviousPastes(),function(q,s){var t=$('
  • ').appendTo(j);var p=$("").attr("href",s.link).text(s.prefix+s.displayDate).appendTo(t);if(vizhash.supportCanvas){var r=zerobin.getPasteId(s.link);var o=vizhash.canvasHash(r,24,24).canvas;p.prepend($(o).addClass("vhash"))}if(s.link.replace(/#[^#]+/,"")===window.location.pathname){t.addClass("active");p.click(function(){window.location.reload()})}})})}}$(".btn-clone").click(function(n){n.preventDefault();$(".submit-form").show();$(".paste-form").hide();$("#content").val(zerobin.getPasteContent()).trigger("change")});$(".clone .btn-danger").click(function(n){n.preventDefault();$(".submit-form").hide();$(".paste-form").show()});if(zerobin.support.fileUpload){var k=function(n){var e=new FileReader();e.onload=function(o){$("#content").val(o.target.result).trigger("change")};e.readAsText(n[0])};var c=$("#file-upload");var b=$(".btn-upload");try{b.val("Uploading...");b.prop("disabled",true);c.change(function(){k(this.files)})}catch(d){zerobin.message("error","Could no upload the file","Error");b.val("Upload File");b.prop("disabled",false)}b.prop("disabled",false);b.val("Upload File");c.mouseover(a($(this).css,"cursor","pointer"))}$(".close").live("click",function(n){n.preventDefault();$(this).parent().fadeOut()});$(".email-link").each(function(o,p){var r=$(this);var e=r.attr("title").replace("__AT__","@");var q=r.text().replace("__AT__","@");var n=$(''+q+"");r.replaceWith(n)});$("#wrap-content").each(function(e,n){$(n).show()})})})(); \ No newline at end of file +(function(){sjcl.random.startCollectors();$.ajaxSetup({cache:true});function a(c){var b=arguments;return function(){return c.apply(c,Array.prototype.slice.call(b,1))}}window.zerobin={version:"0.1",encrypt:function(f,g,d,b,e,c){setTimeout(function(){g=sjcl.codec.utf8String.toBits(g);if(d){d()}setTimeout(function(){g=sjcl.codec.base64.fromBits(g);if(b){b()}setTimeout(function(){g=lzw.compress(g);if(e){e()}setTimeout(function(){g=sjcl.encrypt(f,g);if(c){c(g)}},250)},250)},250)},250)},decrypt:function(f,g,d,b,e,h,c){setTimeout(function(){try{g=sjcl.decrypt(f,g);if(b){b()}setTimeout(function(){try{g=lzw.decompress(g);if(e){e()}setTimeout(function(){try{g=sjcl.codec.base64.toBits(g);if(h){h()}setTimeout(function(){try{g=sjcl.codec.utf8String.fromBits(g);if(c){c(g)}}catch(l){d(l)}},250)}catch(k){d(k)}},250)}catch(j){d(j)}},250)}catch(i){d(i)}},250)},makeKey:function(){return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8,0),0)},getFormatedDate:function(b){b=b||new Date();return((b.getMonth()+1)+"-"+b.getDate()+"-"+b.getFullYear())},getFormatedTime:function(c){c=c||new Date();var e=c.getHours();var b=c.getMinutes();var d=c.getSeconds();if(e<10){e="0"+e}if(b<10){b="0"+b}if(d<10){d="0"+d}return e+":"+b+":"+d},numOrdA:function(d,c){return(d-c)},getLocalStorageKeys:function(b){b="zerobinV"+(b||zerobin.version);var d=[];for(var c in localStorage){if(c.indexOf(b)!==-1){d.push(c)}}d.sort();d.reverse();return d},getTinyURL:function(d,c){var b="http://is.gd/create.php?format=json&url=";$.getJSON(b+encodeURIComponent(d)+"&callback=?",function(e){c(e.shorturl)})},support:{localStorage:(function(){var b=!!(localStorage);$("html").addClass((b?"":"no-")+"local-storage");return b})(),history:(function(){var b=!!(window.history&&history.pushState);$("html").addClass((b?"":"no-")+"history");return b})(),fileUpload:(function(){var b=window;var c=!!(b.File&&b.FileReader&&b.FileList&&b.Blob);$("html").addClass((c?"":"no-")+"file-upload");return c})()},storePaste:function(c,b){b=b||new Date();b=(b.getFullYear()+"-"+(b.getMonth()+1)+"-"+b.getDate()+" "+zerobin.getFormatedTime(b));var d=zerobin.getLocalStorageKeys();if(localStorage.length>19){void localStorage.removeItem(d[19])}localStorage.setItem("zerobinV"+zerobin.version+"#"+b,c)},getPreviousPastes:function(){var c=[],d=zerobin.getLocalStorageKeys(),b=zerobin.getFormatedDate();$.each(d,function(g,f){var j=f.replace(/^[^#]+#/,"");var e=j.match(/^(\d+)-(\d+)-(\d+)\s/);e=e[2]+"-"+e[3]+"-"+e[1];var h="the ";if(e===b){e=j.split(" ")[1];h="at "}c.push({displayDate:e,prefix:h,link:localStorage.getItem(f)})});return c},parseUrl:(function(){var b=document.createElement("div");b.innerHTML="";return function(c){b.firstChild.href=c;b.innerHTML=b.innerHTML;return b.firstChild}})(),getPasteId:function(b){var c=b?zerobin.parseUrl(b):window.location;return c.pathname.replace(/\/|paste/g,"")},getPasteKey:function(b){var c=b?zerobin.parseUrl(b):window.location;return c.hash.replace("#","").replace(/(\?|&).*$/,"")},getPasteContent:function(){var b="";$("#paste-content li").each(function(c){b=b+$(this).text()+"\n"});return b},count:function(h,d){var g=/(\r?\n|\r)/g;var c=/(\r?\n|\r|\s+)/g;d=d||{};d.lineBreaks=d.lineBreaks||1;var f=h.length,e=f-h.replace(/[\u0100-\uFFFF]/g,"").length,b=f-h.replace(g,"").length;return f+e+Math.max(0,d.lineBreaks*(b-1))},message:function(d,e,f,b,g){$(window).scrollTop(0);if(b){$(".alert-"+d).remove()}var c=$("#alert-template").clone().attr("id",null).addClass("alert alert-"+d);$(".message",c).html(e);if(f){$(".title",c).html(f)}else{$(".title",c).remove()}c.prependTo($("#main")).show("fadeUp",g)},progressBar:function(b){var d=$(b);var c={container:d,elem:d.find(".bar")};c.set=function(f,e){c.elem.text(f).css("width",e)};return c}};$(function(){$(".btn-primary").live("click",function(s){s.preventDefault();var p=$("textarea").val();var n=zerobin.count($("#content").val());var o=n>zerobin.max_size;var r=Math.round(n/1024);var u=Math.round(zerobin.max_size/1024);if(o){zerobin.message("error",('Your file is '+r+"KB. You have reached the maximum size limit of "+u+"KB."),"Warning!",true)}if(!o&&p.trim()){var x=$("input, textarea, select, button").prop("disabled",true);var t=zerobin.progressBar("form.well .progress");t.container.show();t.set("Converting paste to bits...","25%");try{var w=$("#expiration").val();var v=zerobin.makeKey();zerobin.encrypt(v,p,a(t.set,"Encoding to base64...","45%"),a(t.set,"Compressing...","65%"),a(t.set,"Encrypting...","85%"),function(e){t.set("Sending...","95%");var y={content:e,expiration:w};$.post("/paste/create",y).error(function(z){x.prop("disabled",false);t.container.hide();zerobin.message("error","Paste could not be saved. Please try again later.","Error")}).success(function(A){t.set("Redirecting to new paste...","100%");if(A.status==="error"){zerobin.message("error",A.message,"Error");x.prop("disabled",false);t.container.hide()}else{var z="/paste/"+A.paste+"#"+v;if(zerobin.support.localStorage){zerobin.storePaste(z)}window.location=(z)}})})}catch(q){x.prop("disabled",false);t.container.hide();zerobin.message("error","Paste could not be encrypted. Aborting.","Error")}}});var f=$("#paste-content").text().trim();var i=zerobin.getPasteKey();var h=false;if(f&&i){$.getScript("/static/js/vizhash.min.js").done(function(n,o){if(vizhash.supportCanvas){var e=vizhash.canvasHash(zerobin.getPasteId(),24,24);$('').click(function(p){p.preventDefault();if(confirm("This picture is unique to your paste so you can identify it quickly. \n\n Do you want to know more about this?")){window.open("http://is.gd/IJaMRG","_blank")}}).prependTo(".lnk-option").append(e.canvas)}});var l=$("input, textarea, select, button").prop("disabled",true);var g=zerobin.progressBar(".well form .progress");g.container.show();g.set("Decrypting paste...","25%");zerobin.decrypt(i,f,function(){g.container.hide();zerobin.message("error","Could not decrypt data (Wrong key ?)","Error")},a(g.set,"Decompressing...","45%"),a(g.set,"Base64 decoding...","65%"),a(g.set,"From bits to string...","85%"),function(e){$("#paste-content").text(e);e="";g.set("Code coloration...","95%");setTimeout(function(){ZeroClipboard.setMoviePath("/static/js/ZeroClipboard.swf");var o=new ZeroClipboard.Client();var n=function(){o.reposition()};o.addEventListener("mouseup",function(){$("#clip-button").text("Copying paste...");o.setText(zerobin.getPasteContent())});o.addEventListener("complete",function(){$("#clip-button").text("Copy to clipboard");zerobin.message("info","The paste is now in your clipboard","",true,n)});o.glue("clip-button");window.onresize=n;$("#short-url").click(function(p){p.preventDefault();$("#short-url").text("Loading short url...");zerobin.getTinyURL(window.location.toString(),function(q){o.setText(q);$("#copy-success").hide();zerobin.message("success",''+q+"","Short url",true,n);$("#short-url").text("Get short url")})});$(".close").off().live("click",function(p){p.preventDefault();$(this).parent().fadeOut(n)});prettyPrint();$("#paste-content").addClass("done");g.set("Done","100%");g.container.hide();l.prop("disabled",false)},250)})}$(".paste-option select").live("change",function(){$(".paste-option select").val($(this).val())});$("#content").elastic();$("#content").live("keyup change",function(){if($("#content").height()<400){$(".paste-option.down").remove()}else{if($(".paste-option").length===1){$(".paste-option").clone().addClass("down").appendTo("form.well")}}});if(zerobin.support.localStorage){var j=$(".previous-pastes"),m=zerobin.getPreviousPastes();if(m.length){$.getScript("/static/js/vizhash.min.js").done(function(e,n){j.find(".item").remove();$.each(zerobin.getPreviousPastes(),function(q,s){var t=$('
  • ').appendTo(j);var p=$("").attr("href",s.link).text(s.prefix+s.displayDate).appendTo(t);if(vizhash.supportCanvas){var r=zerobin.getPasteId(s.link);var o=vizhash.canvasHash(r,24,24).canvas;p.prepend($(o).addClass("vhash"))}if(s.link.replace(/#[^#]+/,"")===window.location.pathname){t.addClass("active");p.click(function(){window.location.reload()})}})})}}$(".btn-clone").click(function(n){n.preventDefault();$(".submit-form").show();$(".paste-form").hide();$("#content").val(zerobin.getPasteContent()).trigger("change")});$(".clone .btn-danger").click(function(n){n.preventDefault();$(".submit-form").hide();$(".paste-form").show()});if(zerobin.support.fileUpload){var k=function(n){var e=new FileReader();e.onload=function(o){$("#content").val(o.target.result).trigger("change")};e.readAsText(n[0])};var c=$("#file-upload");var b=$(".btn-upload");try{b.val("Uploading...");b.prop("disabled",true);c.change(function(){k(this.files)})}catch(d){zerobin.message("error","Could no upload the file","Error");b.val("Upload File");b.prop("disabled",false)}b.prop("disabled",false);b.val("Upload File");c.mouseover(a($(this).css,"cursor","pointer"))}$(".close").live("click",function(n){n.preventDefault();$(this).parent().fadeOut()});$(".email-link").each(function(o,p){var r=$(this);var e=r.attr("title").replace("__AT__","@");var q=r.text().replace("__AT__","@");var n=$(''+q+"");r.replaceWith(n)});$("#wrap-content").each(function(e,n){$(n).show()})})})(); \ No newline at end of file