The Identification Number and Password fields need to be filled in. Moreover, you cannot send messages devoid of contents Adding further data is not allowed because this topic has been closed Print You provided no password: you have to write it in the textfield beside the command delete for the topic you want to delete Are you sure you want to delete this comment? You did not cast a vote. You need to cast a vote by selecting a radio button. Impossible to proceed
 
member picmember pic
 
Snippets of ALBERTO
 
info Below you can find the text of the snippet you want to read, and the list of the other snippets by this author if available.
What are snippets?
Share Share on MySpace Delicious Delicious
Javascript Make A Tabula Recta Matrix. Crypt And Decrypt With Vigenere Cipher
Snippet: Identification Number »   Snippet: Inclusion syntax »
Wednesday August 29, 2007 - 07:10:57
Visitors: 9,251 Daily average: 9 Characters (in origin): 4,296 (pages: ~ 2)
Tagged by its author as: Programming Javascript
Permalink Cast your vote for this topic? click here Printable version: click here
OBJECTIVE: make a tabula recta. Optionally use it to cipher or decipher using it as a Vigenere Table  
function vigenere(alphabet, keyword, textToCipher, decrypt){
if(typeof alphabet!="string" || !alphabet){alphabet='abcdefghijklmnopqrstuvwxyz';};
var output=[];
for(var i=0; i<alphabet.length; i++){ output[++output.length-1]=alphabet.substring(i)+alphabet.substring(0, i); }
if(typeof keyword=="string" && typeof textToCipher=="string" &&
keyword && textToCipher){
var outputText=''; keyword=keyword.split(''); textToCipher=textToCipher.split('');
	for(var t=0, k=0; t<textToCipher.length; t++, k++){
		if(k>=keyword.length){k=0;};
		var row=alphabet.indexOf( keyword[k].toLowerCase() );
		var col=textToCipher[t].toLowerCase();
		if(alphabet.indexOf(col)<0 || row<0){return false;};
		if(!decrypt){ outputText+=output[row].charAt( alphabet.indexOf(col) ); }
		else{ outputText+=alphabet.charAt( output[row].indexOf(col) ); };
	}
return outputText;
}
return output;
/*keep this comment to reuse freely
http://www.fullposter.com/?1 */}
INPUTS: first input a String. If passed as an empty string, defaults to a standard alphabet exclusive of white space char.  
If you want to pass an alphabet yourself you have to follow these rules: only lowercase chars, no duplicates present. The alphabet may include also numbers and punctuations if you prefer so.  
If you want the function not to be case insensitive, just remove from the codes all the strings .toLowerCase() and include in the alphabet both the uppercase and lowercase versions of any char.  
 
Second input a String. If you pass it, the function instead of returning a tabula recta will return a string. If passed, this string must be the keyword you want to use to produce the cipher. To know what it means please be sure you know how a Vigenere Table works.  
If passed, any char present in this string must be present in the alphabet too.  
 
Third input a String. If you pass it, the function instead of returning a tabula recta will return a string. If passed, this string must be the plain text you want to use to cipher. To know what it means please be sure you know how a Vigenere Table works.  
If passed, any char present in this string must be present in the alphabet too.  
 
Last input if zero, the function encrypts. If number 1, it decrypts.  
In both cases the second argument is the keyword. The third argument instead, if you want to crypt, must be the plain text, or must be the cipher if you want to decrypt.  
Encryption and decryption work correctly only if you are using the same tabula recta.  
 
RETURNS: array of strings if no argument or only one argument is present, otherwise a string.  
If the inputs are wrong or the chars present in either of the second and third argument (if present) cannot be found in the alphabet, it returns boolean false.  
 
CAVEATS: please refer to the previous inputs description.  
Vigenere tables are a cipher that can be broken by cryptoanalysis (Kasiski examination * and Babbage * ).  
Shuffling the rows may increase cipher safety.  
Using a one time pad may make the cipher truly safe.  
 
Never use as keyword a one string long keyword whose unique char is the first one present in the alphabet: that ciphers the plain text as plain text.  
 
By default the alphabet does not include an empty space as a char. If your input text to cipher/decipher is inclusive of white spaces, you must include one white space also in the input alphabet (either directly in the code, or passing your alphabet of choice as the function first argument).  
 
Example:  
alert( vigenere().join("\n") );
alert( vigenere('', 'lemonlemonle', 'attackatdawn', 0) );
alert( vigenere('', 'lemonlemonle', 'lxfopvefrnhr', 1) );
Printable version To exclude hyperlinks from the print, check the checkbox »
Rss
Cast your vote for this topic To perform this operation it is not necessary to be Full Poster members.
«Negative Positive»
Click here to save your vote (Current average: 0.00, Voters: 0)
Other topics
This subscriber has a blog too: Read the blog. Shoutbox: 81 reviews: 158
Visitors: 9,251
Daily average: 9
Overall visits to all the topics: 1,623,699
Daily average (Calculated from the website subscription day): 1,150.74
Optional sorting commands:
Normal order: click here
Order by amount of visits: click here
Order by category: Programming Javascript
Current order: normal
Other categories available for this author (Limited data report: 100):
Advice: Martial Arts and Self Defense(1), Books(225), Critical Reviews and Essays(5), Dictionaries(1), Emergency Care(4), Epistles Letters and Advice(5), Fantasy Epics and Fables(1), History and Documents(5), Humor and Jokes(1), Music and Lyrics(6), News Digests and Press Reviews(1), Novels Poetry and Stories(3), Philosophy Reviews(1), Programming(3), Programming Ajax(1), Programming Javascript(65), Programming Php(47), Quotes(1), Religion Esoterica and Spirituality(9), Scientifical Reviews(4), Self Improvement(1), Tarots(1)
Showing topics: 1, 20
Available total: 394
View only a list of the snippets by this author: click here.
Other topics available for this author: click on any title below to view the complete item:
Javascript Ajax Pass An Array To Php Or Server Rebuild The Correct Array Identification Number: 394 Saturday March 13, 2010 - 11:48:01 Visitors: 1,774 Javascript DOM: Make Spreadsheet Editable Table Add Header Cells, Collect Inputs Identification Number: 393 Friday March 12, 2010 - 12:41:32 Visitors: 1,813 Emil Cioran: On the Heights of Despair. A Selection. Identification Number: 392 Sunday February 28, 2010 - 11:06:25 Visitors: 1,155 Php Check Whether A Web Site Or A Web Resource Exists/Responds Identification Number: 391 Saturday February 27, 2010 - 23:05:51 Visitors: 1,661 Sia Il Nulla E Nulla Fu Identification Number: 390 Tuesday February 9, 2010 - 22:24:03 Visitors: 1,695 Php: Get Value Of Specific Html Meta Tag Identification Number: 389 Thursday September 24, 2009 - 14:00:09 Visitors: 4,243 Php Given Url Fetch Youtube Video Codes Embed/Include Video In Other Webpage Identification Number: 388 Saturday September 19, 2009 - 02:03:02 Visitors: 4,354 Php Find Length Of Texts Or Longest Within Instances Of A Given Html Tag Type Identification Number: 387 Saturday September 19, 2009 - 00:24:26 Visitors: 3,726 Riflessioni Sulla Morte Di Carlotta Fondelli Identification Number: 386 Thursday July 30, 2009 - 15:29:52 Visitors: 4,898 Henri Poincaré: Mathematical Creation Identification Number: 385 Tuesday June 16, 2009 - 01:05:38 Visitors: 4,066 Pubblicita' Per Me Stesso: Risposte Pertinenti A Quiz E Domande Impertinenti Identification Number: 384 Friday May 29, 2009 - 01:49:26 Visitors: 4,080 A Collection Of Brief And Famous Or Wise Quotations Identification Number: 383 Monday May 11, 2009 - 06:09:06 Visitors: 4,796 Bertrand Russell: A Free Man's Worship Identification Number: 382 Tuesday May 5, 2009 - 08:41:14 Visitors: 4,403 Protocolli Del Soccorritore? Alla Lettera Please, E Con Il Concorso Di Tutti. Identification Number: 381 Wednesday April 29, 2009 - 20:09:35 Visitors: 4,968 Entropy Revised - At A Glance Identification Number: 380 Wednesday April 29, 2009 - 20:07:08 Visitors: 4,457 Everyday's De Profundis Identification Number: 379 Tuesday April 28, 2009 - 00:10:09 Visitors: 4,696 Javascript Invert Checkbox Status: Uncheck Checked, Check Unchecked. Identification Number: 378 Sunday April 5, 2009 - 12:46:38 Visitors: 5,862 Isaac Newton: Observations upon the Prophecies: Of the Prophetic Language Identification Number: 377 Saturday March 21, 2009 - 23:12:43 Visitors: 4,275 L' Unica Cosa Che Conta E' Lo Yoga Identification Number: 376 Sunday March 15, 2009 - 09:03:00 Visitors: 5,095 Linee Guida Universali Per Operatori Angelici Consegnanti Messaggi Identification Number: 375 Friday March 13, 2009 - 00:15:35 Visitors: 4,966
««« Previous Next »»»
External services
This page of this subscriber uses external services: Hide

Footers

search profiles Join Update poster
reviews Blog Snippets Polls
Favourite web sites Shoutbox Chat Statistics
frequently asked questions Manuals Terms Of Service Contact Full Poster
Applications Discussion groups Free Area Events
Copyright © Full Poster - 2006, 2010 - All rights reserved