LAMPIRAN A : LISTING PROGRAM
File : chrome.manifest content addonta chrome/ style chrome://global/content/customizeToolbar.xul chrome://addonta/content/button.css # Thunderbird compose Overlay chrome://messenger/content/messengercompose/ messengercompose.xul chrome://addonta/content/button.xul
File : install.rdf
<em:targetApplication> <em:file>
Universitas Sumatera Utara
File : button.css #button-enkripsi, #wrapper-button-enkripsi {list-style-image: url("chrome://addonta/content/buttonenkripsi.png");} .addonta {-moz-image-region: rect( 0px 24px 24px
0px);}
.addonta:hover {-moz-image-region: rect(24px 24px 48px
0px);}
[iconsize="small"] .addonta {-moz-image-region: rect( 0px 40px 16px 24px);} [iconsize="small"] .addonta:hover {-moz-image-region: rect(24px 40px 40px 24px);} #button-dekripsi, #wrapper-button-dekripsi {list-style-image: url("chrome://addonta/content/buttondekripsi.png");} .addonta {-moz-image-region: rect( 0px 24px 24px
0px);}
.addonta:hover {-moz-image-region: rect(24px 24px 48px
0px);}
[iconsize="small"] .addonta {-moz-image-region: rect( 0px 40px 16px 24px);} [iconsize="small"] .addonta:hover {-moz-image-region: rect(24px 40px 40px 24px);}
button.xul /*Referensi utama perancangan dokumen XUL overlay https://developer.mozilla.org/ */
diperoleh pada
<script type="application/javascript" src="chrome://addonta/content/MasseyOmura.js"/>
Universitas Sumatera Utara
File : MasseyOmura.js var Massey={ getBodyText: function(){ //untuk mengambil teks dari body email var editor = window.gMsgCompose.editor; var text = editor.outputToString('text/plain', editor.eNone) return text; }, splittt: function(){ var karakter = this.getBodyText(); var kalimat = ""; var hasil = ""; var e = new Array; e = karakter.split("\r\n"); var n = e.length; if(karakter==""){ window.alert("Anda belum mengetikkan pesan !!!"); } else{
for (var i=0; i<e.length; i++){ } if (e[n-1] == ""){ e.pop(); } var m = e.length; if(m == 1){ kalimat = e[0]; hasil = kalimat;
Universitas Sumatera Utara
} else{
},
}
var a = m-1; for ( var i=0; i < m-1; i++){ kalimat = e[i]; hasil = hasil+kalimat+"#"; } hasil = hasil + e[a];
} return hasil;
getDecimalfromASCII: function(){//untuk mengambil nilai desimal dari kode ASCII var karakter =this.splittt(); var simpan = new Array();
},
for(var i=0; i
getASCIIfromDecimal: function(masukan){ //untuk mengubah nilai desimal ke dalam kode ASCII var karakter = masukan; var simpan = new Array();
},
for(var i=0; i
expmod: function(base, exp, mod){ // modulo eksponensial if (exp == 0) return 1; if (exp % 2 == 0){ return Math.pow((this.expmod(base, (exp / 2), mod)), 2) % mod; } else { return (base * (this.expmod( base, (exp - 1), mod))) % mod; } }, lehmann: function() { //untuk menghasilkan bilangan prima dengan LPG var prima=false; var count=0; var p; var a=[2,3,5,7,11,13,17,19,23,29,31,37]; var L; var pangkat;
Universitas Sumatera Utara
var var var var var var var var var
JumlahDigitPrima; cekP=false; cekA=false; str; bil1=""; bil2=""; bil3=""; bil4=""; cek=false;
while (prima==false){ cekP=false; while (cekP==false){ p=Math.floor((Math.random()*10000000)+1); if ((p%2)!=0){ cekP=true; } } bil4 = p; str = p.toString(); JumlahDigitPrima = parseInt(str.length); for (var i=0; i<JumlahDigitPrima; i++){ bil1 = a[i]+"-"+p+" "+bil1; pangkat=(p-1)/2; var ab = this.expmod(a[i],pangkat,p); if (ab<0){ L=ab+p; } else{ L=ab; } bil2 = L+"-"+p+" "+bil2; if ((L==1)){ prima=true; } else{ var x; x=L-p; bil3=x+"-"+p+" "+bil3; if (x==(-1)){ prima=true; } else{ prima=false; break; } } } } },
return bil4;
kuncidA: function(p, eA){ //untuk menghasilkan kunci dekripsi var dA = 1; var hasildA = 0;
Universitas Sumatera Utara
},
while(hasildA!=1){ var b = dA*eA; dA++; hasildA = b % (p-1); } return (dA-1);
gcd: function(x, y){ while (y!=0){ var z = x % y; x = y; y = z; } return x; }, encryptkey: function(p){ //untuk menghasilkan kunci enkripsi var hasil = 0; var prima = p;
},
while (hasil!=1){ var eA = Math.floor((Math.random()*1000000)+1); while (eA < 2 || eA > prima-1){ eA = Math.floor((Math.random()*1000000)+1); } hasil = this.gcd(eA,prima-1); } return eA;
decryptkey: function(p, eA){ var dA; var prima = p;
},
dA = this.kuncidA(prima, eA); return dA;
simpan: function(p,eA){ //untuk menyimpan bilangan prima dan kunci enkripsi
},
var dAKey = this.decryptkey(p,eA); var prime = p; var savekey = prime +" "+ dAKey; var binKey = savekey; var dir = FileIO.get('ProfD'); var fin='\\extensions\\savedKey.txt'; var path=dir.path + fin; var fileIn = FileIO.open(path); FileIO.write(fileIn,binKey);
getKey: function(){ //untuk mengambil kunci enkripsi var var var var
dir = FileIO.get('ProfD'); fin='\\extensions\\savedKey.txt'; path=dir.path + fin; fileIn = FileIO.open(path);
Universitas Sumatera Utara
var ambilkunci = FileIO.read(fileIn); var str = ambilkunci.split(" "); },
return str;
enkripsi: var var var var var
function(){ cipher = new Array(); prima; C1; hasil =""; teksss = new Array();
//Mendapatkan teks yg ada di body var karakter = this.splittt(); //Mengambil karakter terakhir dari teks tersebut var stringLength = karakter.length; var akhir = stringLength - 1; var akhir2; var lastChar = karakter[akhir]; var flag = 0; if(lastChar == "*"){ teksss = karakter.split(" "); var panjang = teksss.length; akhir2 = panjang-2; prima = teksss[akhir2]; teksss.pop(); teksss.pop(); flag =0; } else{
}
teksss = this.getDecimalfromASCII(); prima = this.lehmann(); flag =1;
var eA; eA = this.encryptkey(prima); this.simpan(prima,eA); for (var k=0; k
Universitas Sumatera Utara
} hasil = hasil+"*"; var editor = GetCurrentEditor(); var editor_type = GetCurrentEditorType(); editor.beginTransaction(); editor.beginningOfDocument(); // seek to beginning
},
editor.selectAll(); editor.cut(); editor.selectAll(); editor.cut(); editor.insertText(hasil); editor.endTransaction();
dekripsi: var var var var var var var var var var
function(){ getText = this.splittt(); str = getText; pesan = str.split(" "); flag = 0; kunci = this.getKey(); prima = kunci[0]; dA = kunci[1]; hasildekripsi=""; cipher3 = new Array(); C3;
//Mengambil karakter terakhir dari teks di body var stringLength = str.length-1; var lastChar = str[stringLength]; if(lastChar == "*"){ flag = 1; pesan.pop(); } else{ }
flag = 0;
for (var i=0; i < (pesan.length); i++){ var isi = pesan[i]; C3 = this.expmod(isi,dA,prima); cipher3[i] = C3; } if(flag == 0 ){ var getASCII = new Array(); for (var i = 0; i
Universitas Sumatera Utara
}
} else {
}
},
for (var j=0; j
var editor = GetCurrentEditor(); var editor_type = GetCurrentEditorType(); editor.beginTransaction(); editor.beginningOfDocument(); // seek to beginning editor.selectAll(); editor.cut(); editor.selectAll(); editor.cut(); editor.insertText(hasildekripsi); editor.endTransaction();
}, FileIO = { open
: function(path) { try { var file = Components.classes['@mozilla.org/file/local;1'].createInstance(Compon ents.interfaces.nsILocalFile); file.initWithPath(path); return file; } catch(e) { return false; } }, read
: function(file, charset) { try { var data = new String(); var fiStream = Components.classes['@mozilla.org/network/file-inputstream;1'].createInstance(Components.interfaces.nsIFileInputStream); var siStream = Components.classes['@mozilla.org/scriptableinputstream;1'].createInst ance(Components.interfaces.nsIScriptableInputStream); fiStream.init(file, 1, 0, false); siStream.init(fiStream); data += siStream.read(-1); siStream.close(); fiStream.close(); return data; } catch(e) { return false; } },
Universitas Sumatera Utara
write
: function(file, data) { try { var foStream = Components.classes['@mozilla.org/network/file-outputstream;1'].createInstance(Components.interfaces.nsIFileOutputStream); var flags = 0x02| 0x08 | 0x20; // wronly | create | truncate foStream.init(file, flags, 0664, 0); foStream.write(data, data.length); foStream.close(); return true; } catch(e) { return false; } }, get
: function(type) { try { var dir = Components.classes['@mozilla.org/file/directory_service;1'] .createInstance(Components.interfaces.nsIProperties) .get(type, Components.interfaces.nsIFile); return dir; } catch(e) { return false; } } }
Universitas Sumatera Utara