• Tidak ada hasil yang ditemukan

LAMPIRAN A : LISTING PROGRAM

N/A
N/A
Protected

Academic year: 2021

Membagikan "LAMPIRAN A : LISTING PROGRAM"

Copied!
13
0
0

Teks penuh

(1)

LAMPIRAN A : LISTING PROGRAM

Basic.java

package ferluleapp; /** * * @author Ratna */

public class basic {

//fungsi untuk menghitung modulus dalam pangkat yang besar public static int modExp(int a, int b, int x) {

int c = 1 ;

for (int i = 0 ; i < b ; i++ ){ c = (a * c) % x;

}

return c; }

//membuat daftar karakter dalam array public static char codeChar[] = {

' ','1','2','3','4','5','6','7','8','9','0','-','=','!','@','#','$','%','^','&','*','(',')','_','+','a','b','c','d' ,'e','f', 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w',' x','y','z','A','B','C','D','E','F','G','H','I','J','K', 'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',',','.',' /',';','‘','[',']','\'','<','>','?',':','“','{','}', '|','`','~','€','£','¥','©','β' };

//merubah karakter menjadi kode

public static int charToCode(char m){ int codeC = 0;

for (int i = 0 ; i < codeChar.length; i++) { if (m == codeChar[i]){ codeC = i; break; } } return codeC; }

//merubah kode menjadi karakter

public static char codeToChar(int co){ char charC = 0;

for (int i = 0 ; i < codeChar.length; i++){ if(co == i){

(2)

break; }

}

return charC; }

//fungsi untuk pangkat dengan inputan n(nilai awal), m(pangkat) public static int mathPow(int n, int m){

int x = 1;

for( int i = 1 ; i <= m ; i++ ){ x = n * x; } return x; } }

Elgamal.java

package ferluleapp; import java.util.Random; /** * * @author Ratna */

public class elgamal {

//fungsi untuk memecah ciphernumber dari proses enkripsi public static String mt(String x){

String result = ""; String a = ""; String b = ""; char resulta = 0; char resultb = 0; if(x.length() == 1){ a = "0"; b = String.valueOf(x.charAt(0)); } else if(x.length() == 2){ a = String.valueOf(x.charAt(0)); b = String.valueOf(x.charAt(1)); } else if(x.length() == 3){ a = String.valueOf(x.charAt(0)); b = String.valueOf(x.charAt(1)) + String.valueOf(x.charAt(2)); } else if(x.length() == 4){ a = String.valueOf(x.charAt(0)) + String.valueOf(x.charAt(1)); b = String.valueOf(x.charAt(2)) + String.valueOf(x.charAt(3)); } resulta = basic.codeToChar(Integer.parseInt(a)); resultb = basic.codeToChar(Integer.parseInt(b));

(3)

result = String.valueOf(resulta)+String.valueOf(resultb); return result;

}

//fungsi proses enkripsi

public static String enkripsi(String str, int keyP){ //[START] Initialize variabel-variabel

Random gen = new Random();

int keyAlpha = 0, keyBeta = 0, keyA = 0; int keyK = 0;

int keyGamma = 0; int keyDelta = 0; int ca = 0;

String cipherText = "";

//[END] Initialize variabel-variabel keyAlpha = prime.isPrimitif(keyP);

//perulangan mencari nilai kunci alpha int tempKeyA = 0;

for( int i = 0 ; i < keyP - 2 ; i++ ){ tempKeyA = gen.nextInt(keyP-2) + 1;

if ( prime.isPrime(tempKeyA) == true && tempKeyA < 1000){ keyA = tempKeyA;

break; }

}

//perulangan kunci alpha menghindari digit kedua dari belakang 0

if( String.valueOf(keyA).length() > 2){ while (

String.valueOf(keyA).charAt(String.valueOf(keyA).length()-2) == '0' ){

for( int i = 0 ; i < keyP - 2 ; i++ ){ tempKeyA = gen.nextInt(keyP-2) + 1;

if ( prime.isPrime(tempKeyA) == true && tempKeyA < 1000){ keyA = tempKeyA; break; } } } }

keyBeta = basic.modExp(keyAlpha, keyA, keyP); cipherText +=

mt(Integer.toString(keyP))+""+mt(Integer.toString(keyA)); for (int i = 0 ; i < str.length() ; i++){

keyK = (int) (Math.random() * (keyP - 2)); // menentukan nilai acak K,dimana K elemen dari 0 ... p-2

ca = basic.charToCode(str.charAt(i)); // merubah char ke bentuk kode

keyGamma = basic.modExp(keyAlpha, keyK, keyP); // menghitung nilai Gamma untuk proses enkripsi

(4)

if ( Integer.toString(keyGamma).length() > 2){ while (

Integer.toString(keyGamma).charAt(Integer.toString(keyGamma).length() - 2) == '0' ){

keyK = (int) (Math.random() * (keyP - 2)); keyGamma = basic.modExp(keyAlpha, keyK, keyP); }

}

keyDelta = basic.modExp((basic.modExp(keyBeta, keyK, keyP)*basic.modExp(ca, 1, keyP)), 1, keyP); // menghitung nilai Delta untuk proses enkripsi

if ( Integer.toString(keyDelta).length() > 2){ while (

Integer.toString(keyDelta).charAt(Integer.toString(keyDelta).length() - 2) == '0' ){

keyK = (int) (Math.random() * (keyP - 2)); keyGamma = basic.modExp(keyAlpha, keyK, keyP); keyDelta = basic.modExp((basic.modExp(keyBeta, keyK, keyP)*basic.modExp(ca, 1, keyP)), 1, keyP);

} } cipherText += mt(Integer.toString(keyGamma))+""+mt(Integer.toString(keyDelta)); } return cipherText; }

// fungsi untuk melakukan proses dekripsi. public static String dekripsi(String txt){ int keyDekrip = 0; int keyDG = 0; int keyDek= 0; int cd = 0; String plainText = ""; String a = "", b = "", c = ""; int q = 0 , n = 1;

String tempKeyP = "", tempKeyA = ""; String tempKeyPa = String.valueOf(basic.charToCode(txt.charAt(0))); String tempKeyPb = String.valueOf(basic.charToCode(txt.charAt(1))); String tempKeyAa = String.valueOf(basic.charToCode(txt.charAt(2))); String tempKeyAb = String.valueOf(basic.charToCode(txt.charAt(3))); if ( tempKeyPb.length() == 3 ){

if(tempKeyPb.substring(0, 1).equals("1") && tempKeyPb.substring(1, 2).equals("0")){

tempKeyPb = tempKeyPb.substring(1, 2) + tempKeyPb.substring(2, 3);

} }

(5)

if ( tempKeyAb.length() == 3 ){

if(tempKeyAb.substring(0, 1).equals("1") && tempKeyAb.substring(1, 2).equals("0")){

tempKeyAb = tempKeyAb.substring(1, 2) + tempKeyAb.substring(2, 3);

} }

int keyP = Integer.valueOf(tempKeyPa+tempKeyPb); int keyA = Integer.valueOf(tempKeyAa+tempKeyAb); txt = txt.substring(4, txt.length());

int[] hh = new int[txt.length()/2];

for (int j = 0 ; j < txt.length()/2 ; j++){

a = String.valueOf(basic.charToCode(txt.charAt(q))); b = String.valueOf(basic.charToCode(txt.charAt(q+1))); q = q + 2; c = a+b; hh[j] += Integer.valueOf(c); } int count = 0; int keyGammaInvers = 0 ; int tempa = 0, tempb = 0;

for ( int i = 0 ; i < (hh.length)/2 ; i++){ keyGammaInvers = keyP - 1 - keyA;

keyDekrip = basic.modExp(hh[count], (keyGammaInvers), keyP);

tempa = basic.modExp(hh[(count+1)], 1, keyP);

keyDG = basic.modExp((tempa * keyDekrip), 1, keyP); plainText += basic.codeToChar(keyDG); count = count + 2; } return plainText; } }

fileChooser.java

package ferluleapp; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import javax.swing.JFileChooser; /** * * @author Ratna */

public class fileChooser {

public static String test() throws IOException { String str = "";

(6)

JFileChooser chooser=new JFileChooser(); int returnVal = chooser.showOpenDialog(null); if(returnVal == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile();

BufferedReader br=new BufferedReader(new FileReader(f)); String st=""; while((st=br.readLine())!=null){ str += st+"\n"; } } return str; }

static void main(String string) {

throw new UnsupportedOperationException("Not yet implemented"); } }

ifPrime.java

package ferluleapp; /** * * @author Ratna */

public class ifPrime {

//fungsi untuk metode Fermat

public static boolean isFermat(int prime){ boolean isFermat = false;

for (int i = 1 ; i < prime ; i++){

if(basic.modExp(i, (prime-1), prime) == 1){ isFermat = true; } else { break; } } return isFermat; }

//fungsi untuk metode Lucas-Lehmer public static int isLuLe(int x){ boolean isLuLe = false; int keymp = 0;

boolean isMersenePrime = false; int mp = basic.mathPow(2, x) - 1; int s = 4; //int n = 0; if (prime.isPrime(mp) == true){ isMersenePrime= true; }

(7)

for ( int i = 3 ; i <= x ; i++){ n++;

s = ((basic.mathPow(s, 2)) - 2 ) % mp; }

if( s == 0 && isMersenePrime == true){ keymp = mp; } return keymp; } }

keyGenerator.java

package ferluleapp; import java.util.Random; /** * * @author Ratna */

//class untuk membangkitkan kunci berdasarkan Fermat atau Lucas-Lehmer

public class keyGenerator {

public static int keyGenFermat(){ int s = 0, t = 0, keyP = 0;

for ( int i = 0 ; i < 5000 ; i++){ s = prime.primeGenerator();

//System.out.println("s : "+s+" : "+ifPrime.isFermat(s)+" : "+prime.isSecurePrime(s));

if( prime.isPrime(s) == true ){

if ( ifPrime.isFermat(s) == true && prime.isSecurePrime(s) == true && s > 100 ){

keyP = s; break; } } else { continue; } } return keyP; }

public static int keyGenLuLe(){ int keyP = 0, t = 0;

Random generator = new Random(); for ( int i = 0 ; i < 50 ; i++){ t = generator.nextInt(50)+1; if ( prime.isPrime(t) == true) { if (t==31){ continue; }

if ( ifPrime.isLuLe(t) != 0 && ifPrime.isLuLe(t) > 255 ){

(8)

break; } else if ( ifPrime.isLuLe(t) == 0) { keyP = 0; } } } return keyP; } }

Prime.java

package ferluleapp; import java.util.Random; /** * * @author Ratna */

public class prime {

//fungsi untuk mengecek bilangan prima public static boolean isPrime(int p){ boolean prime = false;

int c = 0; int b = 1;

for (int i = 0 ; i < p ; i++){ b = b + 1; c = p % b; if ( c == 0 ){ break; } } if ( p == b ){ prime = true; } else { prime = false; } return prime; }

public static boolean isPrimeDouble(double p){ boolean prime = false;

double c = 0; int b = 1;

for (int i = 0 ; i < p ; i++){ b = b + 1;

(9)

if ( c == 0 ){ break; } } if ( p == b ){ prime = true; } else { prime = false; } return prime; }

//fungsi untuk mengecek bilangan prima aman public static boolean isSecurePrime(int x){ int q = 0 ;

q = ( x - 1 ) / 2;

if( isPrime(q) == true ){ return true;

} else {

return false; }

}

//fungsi untuk membangkitkan bilangan acak public static int primeGenerator(){

Random generator = new Random(); int r = generator.nextInt(5000)+256; return r;

}

// fungsi untuk melakukan proses enkripsi //fungsi untuk mengecek bilangan primitif public static int isPrimitif(int keyP){ int q = 0;

int alpha = 0; int alphaS = 0 ; int alphaQ = 0; int tempPrim = 0;

Boolean isPrim = false; Random gen = new Random();

for ( int i = 0 ; i < keyP-2 ; i++ ){ tempPrim = gen.nextInt(keyP-2) + 1; q = (keyP - 1) / 2;

alphaS = basic.modExp(tempPrim, 2, keyP); alphaQ = basic.modExp(tempPrim, q, keyP);

if ( (alphaS == 1 && alphaQ == 1) || (alphaS == 1 || alphaQ == 1) ){ isPrim = false; } else { isPrim = true; alpha = tempPrim; break; }

(10)

}

return alpha; }

(11)

LAMPIRAN B : TABEL KODE KARAKTER

KODE

KARAKTER

KODE

KARAKTER

KODE

KARAKTER

00

<spasi>

34

j

68

R

01

1

35

k

69

S

02

2

36

l

70

T

03

3

37

m

71

U

04

4

38

n

72

V

05

5

39

o

73

W

06

6

40

p

74

X

07

7

41

q

75

Y

08

8

42

r

76

Z

09

9

43

s

77

,

10

0

44

t

78

.

11

-

45

u

79

/

12

=

46

v

80

;

13

!

47

w

81

14

@

48

x

82

[

15

#

49

y

83

]

16

$

50

z

84

\

17

%

51

A

85

<

18

^

52

B

86

>

19

&

53

C

87

?

20

*

54

D

88

:

21

(

55

E

89

22

)

56

F

90

{

23

_

57

G

91

}

24

+

58

H

92

|

25

a

59

I

93

`

26

b

60

J

94

~

27

c

61

K

95

28

d

62

L

96

£

(12)

KODE

KARAKTER

KODE

KARAKTER

KODE

KARAKTER

29

e

63

M

97

¥

30

f

64

N

98

©

31

g

65

O

99

β

32

h

66

P

33

i

67

Q

(13)

CURRICULUM VITAE

Nama

: Ratnaningtyas Yoga Wijayanti

Alamat Sekarang

: Jl. Merak 2 No.80 Ling.XIV Perum Sri Gunting

Alamat Orang Tua

: Jl. Merak 2 No.80 Ling.XIV Perum Sri Gunting

Telp/Hp

: 08982860604

Email

: [email protected]

Riwayat Pendidikan

SD Negeri III Ketaon

dari Tahun 1996 s/d Tahun 2002

SMP Negeri 1 Banyudono

dari Tahun 2002 s/d Tahun 2004

SMP Swasta Raksana Medan

dari Tahun 2004 s/d Tahun 2005

SMA Swasta Raksana Medan

dari Tahun 2005 s/d Tahun 2008

Mahasiswa Ilmu Komputer USU

dari Tahun 2008 s/d Tahun 2013

Keahlian/Kursus yang diikuti:

1. Bahasa Inggris

Referensi

Dokumen terkait

c) 0 jika orang tua tidak memahami tentang konsep ketunarunguan. 2) Pemahaman Pola Layanan Orang tua terhadap Anak Tunarungu dalam.

Orang Tua Agar terjadinya hubungan timbal balik antara sekolah dengan orang tua Pertemua orang tua siswa bkelas VII,VIII,IX Agustus-Oktober 2014 Maret 2015 Orang Tua Siswa Humas

Nama Tahun Masuk/NIM Tempat/Tgl.Lahir Jenis Kelamin Negeri Asal IPK/Yudisium Nomor Ijazah Nama Orang Tua/Wali Alamat. : Naufal Raid

Penelitian ini bertujuan untuk mengetahui (1) bentuk-bentuk perhatian orang tua terhadap proses pendidikan anak di sekolah dasar, (2) hubungan perhatian orang tua dengan putus

Kedua orang tua penulis yang penulis sayangi dan hormati Bapak Sholihan dan Ibu Sri Kuwatun yang senantiasa selalu mengiringi penulis dengan doa yang tiada hentinya,

LAMPIRAN B DATA PENELITIAN B.1 DATA VARIABEL DUKUNGAN ORANG TUA B.2 DATA VARIABEL SELF-COMPASSION... 74 VALIDITAS DAN RELIABILITAS C.1 SKALA DUKUNGAN ORANG TUA C.2 SKALA

Lampiran 2 LEMBAR PERSETUJUAN RESPONDEN INFORMED CONCENT Yang bertanda tangan di bawah ini, saya : Nama : Umur : Jenis Kelamin : Alamat : Pekerjaan : Sebagai orang tua dari :

51 Lampiran 3 Persetujuan Setelah Penjelasan Informed Consent Yang bertanda tangan dibawah ini, saya: Nama : Umur : Jenis kelamin : Alamat : Pekerjaan : Merupakan orang tua dari: