dev-util/idea-* minor fixes
[anomen-overlay.git] / www-apps / pmwiki / cookbook / AesCrypt / aescrypt.php
blobf24c3924ab916cdede1e0aa753a642152181c8ad
1 <?php if (!defined('PmWiki')) exit();
3 /*
4 AesCrypt
6 Copyright 2011-2013 Anomen (ludek_h@seznam.cz)
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
13 $RecipeInfo['AesCrypt']['Version'] = '2013-01-11';
15 SDV($AesCryptKDF, 'sha256_dup');
16 SDV($AesCryptKDFJSCode, "
17 AesCtr.kdf_custom = function(password, nBits, nonce) {
18 return '';
20 ");
21 SDV($AesCryptCipherToken, '(:aes ');
22 SDV($AesCryptEndToken, ':)');
23 SDV($AesCryptPadding, 6);
25 SDV($HTMLStylesFmt['aescrypt'], "
26 #aescrypt_m {
27 position: absolute;
28 z-index: 200;
29 top: 0px;
30 left: 0px;
31 width: 100%;
32 height: 100%;
33 opacity: .4;
34 filter: alpha(opacity=40);
35 /* this hack is so it works in IE
36 * I find setting the color in the css gives me more flexibility
37 * than the PNG solution.
39 background-color:transparent !important;
40 background-color: #333333;
41 /* this hack is for opera support
42 * you can uncomment the background-image if you don't care about opera.
43 * this gives you the flexibility to use any bg color that you want, instead of the png
45 background-image/**/: url('$PubDirUrl/aescrypt/maskbg.png') !important; // For browsers Moz, Opera, etc.
46 background-image:none;
47 background-color:#cccccc;
48 background-repeat: repeat;
49 visibility: hidden;
52 .aescrypt_overlay {
53 visibility: hidden;
54 position: absolute;
55 left: 0px;
56 top: 0px;
57 width:100%;
58 height:100%;
59 text-align:center;
60 z-index: 1000;
63 .aescrypt_overlay div {
64 width:300px;
65 margin: 100px auto;
66 background-color: #ffffff;
67 border:1px solid #000000;
68 padding:15px;
69 text-align:center;
72 #aescrypt_i {
73 float:right;
76 ");
79 $HTMLHeaderFmt['aescrypt_common'] = "
80 <script type=\"text/javascript\" src=\"\$PubDirUrl/aescrypt/aescrypt.js\"></script>
81 <script type=\"text/javascript\" src=\"\$PubDirUrl/aescrypt/main.js\"></script>
82 <script type=\"text/javascript\">
83 // <![CDATA[
85 $AesCryptKDFJSCode
87 /**
88 * Key derivation function selected by AesCryptKDF variable.
90 AesCtr.kdf = function(password, nBits, nonce) {
91 return AesCtr.kdf_$AesCryptKDF (password, nBits, nonce);
94 AesCrypt.AesCryptCipherToken = '$AesCryptCipherToken';
95 AesCrypt.AesCryptEndToken = '$AesCryptEndToken';
96 AesCrypt.AesCryptPadding = $AesCryptPadding;
97 AesCrypt.PubDirUrl = '$PubDirUrl/aescrypt';
99 // ]]>
100 </script>
103 /* generate decryption code */
104 function aescryptMarkup($ciphertext)
106 static $id = 0;
107 $id++;
108 $res = "\n";
109 $res .= "<div id=\"aescrypt_c_$id\" style=\"white-space:pre;display:none;\">$ciphertext</div>";
110 $res .= "<div id=\"aescrypt_d_$id\">";
111 $res .= "<a id=\"aescrypt_a_$id\" href=\"javascript:void (0);\" onClick=\"AesCrypt.decPopup($id);\">";
112 $res .= "[Decrypt]";
113 $res .= "</a>";
114 $res .= "</div>";
115 return $res;
118 Markup('aescrypt',
119 "<[=",
120 "/\\Q$AesCryptCipherToken\\E\\s*(.*?)\\s*\\Q$AesCryptEndToken\\E/se",
121 "aescryptMarkup('$1')");
123 if ($action == 'edit') {
125 if (IsEnabled($EnableGUIButtons)) {
126 $GUIButtons['aescrypt'] = array(750, '', '', '',
127 "<a href='#' onclick='AesCrypt.encPopup();'><img src='\$GUIButtonDirUrlFmt/aescrypt.png' title='Encrypt' /></a>");
128 } else {
129 $MessagesFmt[] = "<input type='button' name='aesButton' value='Encrypt' onClick='AesCrypt.encPopup();'/>";