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,497 Daily average: 9 Tagged by its author as: Programming Javascript Characters (in origin): 4,296 (pages: ~ 2)
Permalink Cast your vote for this topic Remove color and border from headers Printable version
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: 82 reviews: 170
Visitors: 9,497
Daily average: 9
Overall visits to all the topics: 1,670,896
Daily average (Calculated from the website subscription day): 1,153.14
Optional sorting commands:
Normal order: click here
Order by amount of visits: click here
Order by category: Programming Javascript
Current order: by amount of visits
Other categories available for this author (Limited data report: 100):
Advice: Martial Arts and Self Defense(1), Books(226), 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(2), 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: 396
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:
Convert From Javascript Syntax To Php Syntax And From Php To Javascript Identification Number: 93 Thursday August 9, 2007 - 01:44:31 Visitors: 32,415 Javascript DOM Get Parent Nodes: All Nodes Or Specific Node By Id Or By Tag Name Identification Number: 53 Sunday July 1, 2007 - 04:52:01 Visitors: 28,025 Old Man at the Bridge. By Ernest Hemingway (The First Forty-Nine Stories) Identification Number: 75 Thursday July 12, 2007 - 13:32:44 Visitors: 20,350 Javascript Cast And Recast Numerical Value Of Numerical Range Into Another Range Identification Number: 99 Tuesday August 21, 2007 - 00:05:44 Visitors: 18,234 Ezra Pound: Vorticism. Full Text. Identification Number: 133 Sunday October 7, 2007 - 05:29:57 Visitors: 17,386 Simbologie Massoniche: Tavola Di Istruzione Rapida Con Cenni Storici Insoliti Identification Number: 191 Monday December 10, 2007 - 01:16:53 Visitors: 16,496 Striptease. By Roland Barthes. Excerpt From Mythologies Identification Number: 80 Tuesday July 17, 2007 - 02:13:44 Visitors: 16,060 Javascript DOM Sibling Nodes: Report Or Remove nextSibling previousSibling Identification Number: 83 Friday July 20, 2007 - 07:40:56 Visitors: 14,373 Pablo Neruda: 20 Love Poems And A Song Of Despair. Excerpts In English Identification Number: 161 Wednesday October 24, 2007 - 10:05:55 Visitors: 14,211 Javascript DOM: Replace Node, Move Node Or Clone, Swap Nodes Identification Number: 58 Wednesday July 4, 2007 - 05:34:24 Visitors: 13,496 Salvatore Quasimodo: Traduzioni Scelte Dai Frammenti Dei Lirici Greci Identification Number: 126 Thursday September 20, 2007 - 13:54:41 Visitors: 13,223 Pablo Neruda: One Hundred Love Sonnets. Excerpts in English Identification Number: 163 Thursday October 25, 2007 - 12:37:12 Visitors: 13,213 Javascript Dom Insert Text: Update Node Value Of Text nodeType Identification Number: 90 Tuesday August 7, 2007 - 06:51:13 Visitors: 12,575 PHP Make a Balanced Binary Tree From An Input Array Without Duplicates Identification Number: 38 Wednesday June 20, 2007 - 15:43:23 Visitors: 12,116 Javascript Event Handlers addEventListener attachEvent Detect Case Pass Argument Identification Number: 63 Monday July 9, 2007 - 06:15:47 Visitors: 12,086 Javascript To Get And View Html Source Code Of Page Document Or Dom Nodes Identification Number: 59 Thursday July 5, 2007 - 04:26:16 Visitors: 11,821 PHP Array Compare Differences: Find In Arrays Items Identical, Added, Discarded Identification Number: 15 Saturday June 9, 2007 - 06:26:46 Visitors: 11,140 Javascript Split A String Using A Regular Expression Pattern Identification Number: 45 Saturday June 23, 2007 - 20:40:22 Visitors: 10,757 Ernest Hemingway: Notes on the Next War: A Serious Topical Letter. From: By Line Identification Number: 139 Sunday October 14, 2007 - 08:19:07 Visitors: 10,325 Javascript Select Tag Options: Populate With New Values And Texts, Pre Select Identification Number: 32 Sunday June 17, 2007 - 12:49:10 Visitors: 10,022
««« 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