Additions:
A note of efficiency : the kwypt_string method basically double-encrypts a string twice using the rc4 method. This is highly inefficient (effectively tripling string length). But it does add a little more security for public data against brute-force trolling attacks. For basic rc4 encryption, there are encrypt and decrypt methods available. (See [[http://klenwell.googlecode.com/svn/trunk/JS/kwyption/kwyption.core.js kwyption.core.js]] and the [[http://klenwell.googlecode.com/svn/trunk/JS/kwyption/rick4.js Rick 4 class]].)
Additions:
----
CategoryJavascript
CategoryJavascript
Deletions:
Additions:
**working example**
Additions:
**simple example**
var key = 'a simple key';
var plaintext = 'This is top secret. Reveal to no one. Unless they have the precious key.'
TheKwyptor.ini(key);
var ciphertext = TheKwyptor.enkwypt_string(plaintext);
alert(ciphertext);
// will display something like: OLRHqz+$XDS3Mb+R3LOAlF55SiiU1v2ekAnh7$dw9IKMK612$FWKthCTlVg$ykpiwfW61oQ174ea6cc8187d9bbdd96358f1a279db43XuuKI$RrrEPKXGUNGievyp$gNOb@VgQ5Gop
var key = 'a simple key';
var plaintext = 'This is top secret. Reveal to no one. Unless they have the precious key.'
TheKwyptor.ini(key);
var ciphertext = TheKwyptor.enkwypt_string(plaintext);
alert(ciphertext);
// will display something like: OLRHqz+$XDS3Mb+R3LOAlF55SiiU1v2ekAnh7$dw9IKMK612$FWKthCTlVg$ykpiwfW61oQ174ea6cc8187d9bbdd96358f1a279db43XuuKI$RrrEPKXGUNGievyp$gNOb@VgQ5Gop
Additions:
<!-- from head -->
<!-- from body-->
<!-- from body-->
Deletions:
<!-- from body -->
Additions:
<!-- External Script -->
Deletions:
Additions:
%%(javascript)
Deletions:
Additions:
%%(js)
<!-- from head -->
<script type="text/javascript" src="http://klenwell.googlecode.com/svn/trunk/JS/kwyption/kwyption.ini.js"></script>
<!-- from body -->
<!-- SCRIPT -->
<!-- end SCRIPT -->
<!-- THE FORM -->
<div id="kwyption_form" class="js_form">
<form name="kwyptor" id="kwyptor">
<h4>plain text</h4>
<textarea id="plaintext" cols="40" rows="4" onfocus="javascript:this.value='';">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</textarea>
<h4>key</h4>
<input id="keytext" name="keytext" type="text" value="your key here" onfocus="javascript:this.value='';" size="24" />
<div class="bx_group">
<input id="bx_encrypt" name="bx_encrypt" type="button" value="encrypt" onclick="javascript:run_encrypt();" />
<input id="bx_decrypt" name="bx_decrypt" type="button" value="decrypt" onclick="javascript:run_decrypt();" />
</div>
<h4>cipher text</h4>
<textarea id="ciphertext" cols="40" rows="4"></textarea>
</form>
</div>
<!-- end FORM -->
<!-- from head -->
<script type="text/javascript" src="http://klenwell.googlecode.com/svn/trunk/JS/kwyption/kwyption.ini.js"></script>
<!-- from body -->
<!-- SCRIPT -->
<!-- end SCRIPT -->
<!-- THE FORM -->
<div id="kwyption_form" class="js_form">
<form name="kwyptor" id="kwyptor">
<h4>plain text</h4>
<textarea id="plaintext" cols="40" rows="4" onfocus="javascript:this.value='';">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</textarea>
<h4>key</h4>
<input id="keytext" name="keytext" type="text" value="your key here" onfocus="javascript:this.value='';" size="24" />
<div class="bx_group">
<input id="bx_encrypt" name="bx_encrypt" type="button" value="encrypt" onclick="javascript:run_encrypt();" />
<input id="bx_decrypt" name="bx_decrypt" type="button" value="decrypt" onclick="javascript:run_decrypt();" />
</div>
<h4>cipher text</h4>
<textarea id="ciphertext" cols="40" rows="4"></textarea>
</form>
</div>
<!-- end FORM -->
Additions:
the code below is the actual code from [[http://klenwell.googlepages.com/demo.kwyption.htm the demo]] listed above
%%
<script type="text/javascript">
/* Create Kwyption Object */
var debug = 0;
var TheKwyptor = new Kwyption(debug);
TheKwyptor.ini();
function run_encrypt()
{
var TheForm = document.forms['kwyptor'];
var TxtKey = TheForm.elements['keytext'];
var TaPlain = TheForm.elements['plaintext'];
var TaCipher = TheForm.elements['ciphertext'];
if ( TaPlain.value == '' )
{
alert('please enter the text you wish to encrypt in the plain text box');
return;
}
TheKwyptor.set_key(TxtKey.value);
TaCipher.value = TheKwyptor.enkwypt_string(TaPlain.value);
TaPlain.value = '';
return;
}
function run_decrypt()
{
var TheForm = document.forms['kwyptor'];
var TxtKey = TheForm.elements['keytext'];
var TaPlain = TheForm.elements['plaintext'];
var TaCipher = TheForm.elements['ciphertext'];
if ( TaCipher.value == '' )
{
alert('please enter the text you wish to decrypt in the cipher text box');
return;
}
else if ( TxtKey.value == '' )
{
alert('please enter your key in the key field');
return;
}
TheKwyptor.set_key(TxtKey.value);
TaPlain.value = TheKwyptor.dekwypt_string(TaCipher.value);
TaCipher.value = '';
return;
}
</script>
%%
%%
<script type="text/javascript">
/* Create Kwyption Object */
var debug = 0;
var TheKwyptor = new Kwyption(debug);
TheKwyptor.ini();
function run_encrypt()
{
var TheForm = document.forms['kwyptor'];
var TxtKey = TheForm.elements['keytext'];
var TaPlain = TheForm.elements['plaintext'];
var TaCipher = TheForm.elements['ciphertext'];
if ( TaPlain.value == '' )
{
alert('please enter the text you wish to encrypt in the plain text box');
return;
}
TheKwyptor.set_key(TxtKey.value);
TaCipher.value = TheKwyptor.enkwypt_string(TaPlain.value);
TaPlain.value = '';
return;
}
function run_decrypt()
{
var TheForm = document.forms['kwyptor'];
var TxtKey = TheForm.elements['keytext'];
var TaPlain = TheForm.elements['plaintext'];
var TaCipher = TheForm.elements['ciphertext'];
if ( TaCipher.value == '' )
{
alert('please enter the text you wish to decrypt in the cipher text box');
return;
}
else if ( TxtKey.value == '' )
{
alert('please enter your key in the key field');
return;
}
TheKwyptor.set_key(TxtKey.value);
TaPlain.value = TheKwyptor.dekwypt_string(TaCipher.value);
TaCipher.value = '';
return;
}
</script>
%%
Additions:
**license** : [[http://www.opensource.org/licenses/gpl-license.php GPL2]]
**source** : [[http://klenwell.googlecode.com/svn/trunk/JS/kwyption/ google code]]
**demo** : [[http://klenwell.googlepages.com/demo.kwyption.htm klenwell.googlepages.com]]
**source** : [[http://klenwell.googlecode.com/svn/trunk/JS/kwyption/ google code]]
**demo** : [[http://klenwell.googlepages.com/demo.kwyption.htm klenwell.googlepages.com]]
Deletions:
**Source** [[http://klenwell.googlecode.com/svn/trunk/JS/kwyption/ google code]]
**Demo** [[http://klenwell.googlepages.com/demo.kwyption.htm klenwell.googlepages.com]]