SCRIPTING:

Michelle Hunziker

« LUCIFER » STYLE SCRIPTS TO ADD BAITS AND PERFORM SHUFFLINGS WITH CRYPT TEXTS
« Lucifer » was the name that IBM gave to a product and a procedure, which was to become a standard, meant to crypt texts by giving to the cipher a lot of shuffling, in order to make it even harder to analyze.
Therefore I humbly got inspired and gave such name to these scripts since shuffling a crypt and adding baits to it is what they do.

You need to know already the 2 previous files on ciphering we put online:
here (1) and here (2). With this, it's a CRYPTO TRILOGY
November 2001
{ @ }

The model above is Michelle Hunziker
LOADS OF MICHELLE HUNZIKER ON THE NET


Two Scripts: lucifer and cryptoBaits
The codes for lucifer, the script which shuffles a crypt text and can then rebuild it, and cryptoBaits which adds baits to a cipher and is able to remove them later without being fooled.
CryptoBaits requires lucifer, since it uses it.

You probably don't want so complex scripts, none the less they perform two most wanted tasks once you're at cryptology and if you're getting deeper in it: the shuffling and the baits.
Since our cryptology style relies on Vigenere tables, luciferizing and baits are relevant: I do not go into more technicalities, but once found the cipher you can also find the guy with enough brains to decipher, also if it might take years (deciphering "Enigma", the nazi ciphering procedure, required years of focused efforts): the main threat to Vigenere Tables (since every cipher has a potential foe) is the so called "Babbage" analysis which could deduce part of the cipher analyzing the frequency of more recurrent letters: but if you do not only crypt, but you also:

An Acknowledgement
I found very useful the following book (which is NOT a book on programming but sort of a history book) when in these latest days I got engrossed with cryptology:
SIMON SINGH
The Code Book
1999

  1. can rely on different alphabets to build the Vigenere tables (if you do not know what they are, I do urge you to read previous files, like crypto2, Viegenere tables), of your choice.
  2. you can shuffle the crypt so changing all the positions to the cipher
  3. you can add also baits, that is: segment of codes which are not meant to crypt something but just to deceive
  4. eventually, you can rely on the usage of two different keywords to trigger either the crypt or the luciferizing process
Well, once you can do all this, chances are by your side, man!

Anyway, keep in mind: the difference between lucifer and cryptoBaits is (for both yield as a result a shuffling of the text) that lucifer shuffles the existing input text, as opposite to cryptoBaits which adds characters to it, and then invokes lucifer to shuffle the overall amount (original text plus baits, that is).

Away with the chatters, here are your scripts:



function lucifer(message, keyword, cryptDecrypt, alphabet, fragmentWidth){
//Requires: fragmentString function
if(!message){return false};
fragmentWidth=(fragmentWidth)?fragmentWidth:1;
while(message.length%fragmentWidth)
{--fragmentWidth}
if(lucifer.caller&&
lucifer.caller.arguments[0]=="cryptoBaits invokes")
{
return fragmentWidth}
    var fragment=fragmentString(message,fragmentWidth);
if(!keyword){
keyword="UnitedScripters.com";//hint: s different from S
}
if(typeof keyword=="number"){keyword=keyword+""}
if(typeof keyword=="string"){keyword=keyword.split("")};
if(!alphabet){
alphabet="f/7u9kH1Pg:hi(jZl2,mn#"
alphabet+="op&qr'st=c3v{w>xy\z"
alphabet+="A!V5BCD_E}FGe6IJ@KL0M[)bN.Oa<"
alphabet+="Q8R*ST?$U4;W%XY]d-"}
else{//exclude doubles
var alphabet2=alphabet.split("")
var correct=new Array();
for(var e=0;e<alphabet2.length;e++){
var copyFound=0;
for(var c=0;c< correct.length; c++){
if(correct[c]==alphabet2[e]){copyFound=1};
}
if(copyFound){continue};
correct.length++
correct[correct.length-1]=alphabet2[e]
}
alphabet2=correct;
var hold=""
for(var flat=0; flat<alphabet2.length; flat++){
hold+=alphabet2[flat]
}
alphabet2=null;
alphabet=hold;
hold=null;
//doubles excluded
}
var keyLevel=-1
var schemeTracking=new Array(fragment.length);
var scheme=new Array(0)
for(F=0; F<fragment.length; F++){
keyLevel = (keyLevel==keyword.length ||
keyword.length==1)?
0:++keyLevel;
var slot = ( alphabet.indexOf(keyword[keyLevel])!=-1 )?
alphabet.indexOf( keyword[keyLevel] ):keyLevel
var luci = (F<=fragment.length/2)?
parseInt(((fragment.length/2)+F)):
parseInt((F-(fragment.length/2))+1)
slot+=luci
while(slot>fragment.length-1){
slot-=fragment.length;
}
/*online comment*/
  while(schemeTracking[slot]||
schemeTracking[slot]+""=="0"){
  slot=((slot+1)==schemeTracking.length)?0:++slot
  }
schemeTracking[slot]=slot
scheme.length++
scheme[scheme.length-1]=schemeTracking[slot]
}
var output=""
if(!cryptDecrypt){
  for(var FF=0;FF<fragment.length;FF++){
  output+=fragment[scheme[FF]]
  }
}
else{
var outArray=new Array(fragment.length);
for(var s=0;s<scheme.length;s++){
outArray[scheme[s]]=fragment[s]
}
output=outArray.join("")
}
return output
/*keep this comment to reuse freely
http://www.unitedscripters.com */}

/**********************************/

function cryptoBaits(luciferFunc, message, keyword, baitAmount, addOrRemove, alphabet){
//REQUIRES: functions: lucifer, fragmentString
/* online comment */

if(!message||!baitAmount){return false};
bait=(isNaN(parseInt(baitAmount))||
parseFloat(baitAmount)==0)?
1:baitAmount;
if(!keyword){
keyword="UnitedScripters.com";
}
if(typeof( keyword) == "number"){keyword=keyword+""}
if(!alphabet){
alphabet="f/7u9kH1Pg:hi(jZl2,m n"
alphabet+="#op&qr'st=c3v{w>xy\zA!V5BCD_E}"
alphabet+="FGe6IJ@KL0M[)bN.Oa<Q"
alphabet+="8R*ST?$U4;W%XY]d-"}
else{
var alphabet2=alphabet.split("")
var correct=new Array();
for(var e=0;e<alphabet2.length;e++){
var copyFound=0;
for(var c=0;c<correct.length;c++){
if(correct[c]==alphabet2[e]){copyFound=1};
}
if(copyFound){continue};
correct.length++
correct[correct.length-1]=alphabet2[e]
}
alphabet2=correct;
var hold=""
for(var flat=0;flat<alphabet2.length;flat++)
{
hold+=alphabet2[flat]
}
alphabet2=null;
alphabet=hold;
hold=null;
}
luciferFunc="cryptoBaits invokes"
var fragmentWidth=lucifer(message, keyword, 0, alphabet)
luciferFunc=""
var insertIndex = parseInt((keyword.length/2)+1)
insertIndex = keyword.charAt(insertIndex)
insertIndex = (alphabet.indexOf(insertIndex)==-1)?
2:
alphabet.indexOf(insertIndex)
insertIndex = (!addOrRemove)?
(parseInt(message.length/2)+1):
(parseInt( ((message.length- (baitAmount*fragmentWidth))/2)) +1)
if(!addOrRemove){
var baitList=""
for(var B=0;B<baitAmount;B++){
var w=0;
baitList.length++
var snippet=""
while(w<fragmentWidth){
snippet+=alphabet.charAt(
Math.round( Math.random()*alphabet.length-1) )
w++}
baitList+=snippet
}
var m1=message.substring( 0,insertIndex )
var m2=message.substring( insertIndex,message.length )
message=m1+baitList+m2
return lucifer(message, keyword, 0, alphabet, fragmentWidth)
}
else{
var output=lucifer(message, keyword, 1, alphabet, fragmentWidth)
var m1=output.substring(0,insertIndex)
var m2= output.substring(insertIndex+ (baitAmount*fragmentWidth), message.length)
output=m1+m2
return output;
}
/*keep this comment to reuse freely
http://www.unitedscripters.com */}
Ernest Hemingway at the Floridita
a somewhat handsome Ernest Hemingway at the Floridita

Try «LUCIFER» on a string?
Insert a key: (optional)
lucifer: crypt» | decrypt »

a Andre Kertesz photo
an Andre Kertesz photo: hungarian fiddler, 1917, delivered to immortality

Wanna try «CRYPTOBAITS»?
Insert a key: (optional)
# of baits:
cryptoBaits: put» | remove »

Allen Jones, ''Perfect Match'' - 1966/67
U.S marines bracing up to fight the nazis: shot taken 4 minutes before hitting the shore at the notorious Omaha beach, dog green sector


Invoking these scripts
Some quick notes on their workings and how to invoke them

You must keep in mind some very important things if you're to use these scripts:
  1. Since you may want to use them after you've crypt a text with the scripts you can find in the other two files I devoted to cryptology, you must bear in mind that if you crypt, then you add a shuffle with lucifer and eventually you add baits with cryptoBaits, when you go for deciphering the whole stuff, you must proceed in the inverse order, thus if you used:
    1. crypt()
    2. lucifer to shuffle
    3. cryptoBaits to add baits
    when you're at deciphering you must proceed in the specular way:
    1. cryptoBaits with the argument which flags to remove the baits
    2. lucifer with the argument set to rebuild the order (all the orders in these shufflings are built deriving them from the keyword which is passed upon invocation -and if none is passed a default is assigned. In such fashion every text which underwent a shuffling can be safely rebuilt provided the keyword is still the same when you invoke to crypt and when you invoke to deCrypt the very same piece of text)
    3. finally, you can run deCrypt
    4. Obviously, if the order was different, the deciphering process must mirror it as well. I advice to crypt and, if you want to add shuffle and baits, to add first the lucifer shuffling and eventually the baits.
  2. For the crypt and deCrypt functions see the 2nd crypto file; anyway keep in mind that the keyword used for crypt and deCrypt functions can be different from the keyword you use for lucifer. So: use the same keyword (or none: I repeat, there is a default in within the script if no keyword argument is passed) to crypt/decrypt, but you're not supposed to keep using the same one for lucifer/de-lucifer baits/remove-baits.
    This is a strong point, for if you can rely on as many as two keywords, your crypt would be sounder. The length of a key can be whatever you prefer, and the scripts perform validation to avoid stumbling into problems.
Andy Wharol, Marylin
  1. ARGUMENTS for LUCIFER:
    1. message is mandatory, is the text to shuffle
    2. keyword is optional but if you provide it is better!
    3. cryptDecrypt argument flags whether the script must shuffle or rebuild the ordered text: for no value or zero it shuffles, for value 1 or integer it rebuilds the original (provided the keywords match)
    4. alphabet must be a string (in between single quotes at least, that is, so that you can custom the chars that have to be recognized. Please do not include in your keywords chars which are not in the alphabet. Providing a different alphabet when shuffling demands that you pass the same alphabet also when re-ordering: in other words, passing an alphabet is like... providing a 3rd keyword which makes your crypt more and more cryptic... As for the ways you can use these features, we're currently (NOV 2001) preparing the ENDLESS TOKEN file, check our front page to see when it's online and ready.
    5. fragmentWidth argument is optional, and flags the width that each fragment should carry: shuffling a text means, in fact, fragmenting it into pieces and then rearrange these chips. The lower the better, since pieces of one char cause a complete shuffle. I suggest not to set the fragmentWidth, or to set it to 1. Moreover, if this width cannot divide the length of the message, it gets automatically decreased so after all setting it to 1 should be the wiser and safer move (also considering that would make no sense to shuffle chips 10 chars long, for instance, since shuffling is meant to prevent revealing symmetries to appear. It is pretty difficult that such symmetries could ever appear in this crypting system, but if you add also some lucifer and cryptoBaits you're even safer!)
    6. To run these scripts you need to have defined in within the same javascript source also the fragmentString function which can be found here - array7 file.
    7. Example, with basic arguments, for invoking this script:
      lucifer(message,myKeyword,0) to shuffle (all chars since no fragmentWidth has been specified),
      lucifer(message,myKeyword,1) to re-order.
    8. Eventually, to be honest I have a small doubt on the workings of this fragmentWidth argument, so my advice is to never set it (which defaults to 1) or set it to 1. Of course if you set it, anyway, when you decipher you have to be sure that keyword, alphabet, fragmentWidth arguments are all the same (and, obviously, also the text to work on is the right one...!).
    9. If you get starnge results, before arguing these scripts do not work, please consider that you may have inadvertantly crypted the crypt, or forget a keyword, or similar: these scripts do work!
  2. WARNING & ARGUMENTS for CRYPTOBAITS
    1. When dealing with cryptoBaits and your input message is from a TEXTAREA, namely a form field which allows for new lines and carriage returns and tabs the script may be fooled. Instances:
      1. A new line char is what is at the end of a line, and is matched by a carriage return at the beginning of the next line: this means that in a new line there are nothing short but 2 (two) chars hidden to the human sight.
      2. At times these chars are treated like double chars, yielding as an eventual result 3 or 4! The script might be unable to process them properly, thus messing up the indexes for rebuilding a text: and messing up one index, means to mess up also all the subsequent ones. I repeat: a javaScript issue, not a script issue: simply, javaScript doesn't seem to provide programmers with strong enough tools and methods to force the recognition of escaped chars without stumbling into unpredictable mutliplications of them.
        If you use baits, try decrypting your own crypt before using or sending it. This applies only in case you use baits on/from textraea fields.
      3. You should not use or rely on cryptoBaits too much when crypting text from textarea fields.
    2. luciferFunc argument: I apologize but you have to set this always and to zero: it is a flag which, when cryptoBaits invokes lucifer (since it does) instructs lucifer to perform a certain task: if you omit it or do not set it to zero, the function would not work: I repeat do not omit it, just set it to zero: it has to exists someway since lucifer makes a reference through a statement which uses the caller.argument constructor (caller is a reference to a function that invokes the current function) and if the argument is not passed (even though as a zero!) the statement caller.arguments[x] would yield errors you see...! I put it as first argument, although not an intuitive or friendly position, just because I want you to be fully aware that you do have to define it somehow, even if as a ... zero!
  1. message argument is mandatory: the text to which to add or to subtract the baits.
  2. keyword argument is optional, see same consideration made for keyword in lucifer.
  3. baitAmount argument: how many baits you want to include? No limit. But you have to set it, since if you pass it as zero, the script assumes you want no baits and do not proceed. of course if you do not want to set a keyword, remember to set it as a zero: example:
    cryptoBaits(0,message,0,30)
  4. addOrRemove argument: if zero or absent adds the baits, if 1 or integer removes them.
  5. alphabet argument is optional, see consideration for alphabet argument in lucifer.
 
 
 
BACKGROUND: Daniela Pestova