Implementasi Algoritma Kunci Publik Luc dan Algoritma Kompresi Goldbach Codes untuk Perancangan Aplikasi Pengamanan dan Kompresi File
85
Listing Program
Pembangkit Kunci.VB
Public NotInheritable Class LUC
Private Sub New()
End Sub
Private Shared rng As New RNGCryptoServiceProvider()
Public Shared e As BigInteger, N As BigInteger, tN As BigInteger, sN As
BigInteger
Public Shared d As BigInteger
Public Shared p As BigInteger, q As BigInteger
'public static BigInteger [] enk_char;
Private Shared rnd As Byte() = New Byte(3) {}
Public Shared Sub hasil_kunci()
Do While p = q
p = generate_bil_prima()
q = generate_bil_prima()
Loop
N = CType(p * q, BigInteger)
tN = generate_tN(p, q)
sN = lcm(New BigInteger() {CType(p, BigInteger) - 1, CType(q,
BigInteger) - 1, CType(p, BigInteger) + 1, CType(q, BigInteger) + 1})
e = must_gdc_with(tN, sN)
d = InverseModular(e, sN)
System.Diagnostics.Debug.WriteLine(GCD(e, sN))
System.Diagnostics.Debug.WriteLine((d * e) Mod sN)
End Sub
Private Shared Function must_gdc_with(p As BigInteger, n As BigInteger) As
UInt16
Dim c_e As UInt16
Do
rng.GetBytes(rnd)
c_e = BitConverter.ToUInt16(rnd, 2)
Loop While GCD(c_e, p) 1 OrElse c_e >= p OrElse c_e >= n
Return c_e
End Function
Private Shared Function generate_bil_prima() As UInt16
Dim c_prima As UInt16
Do
rng.GetBytes(rnd)
c_prima = CType(BitConverter.ToUInt16(rnd, 0) Mod 150, UInt16)
Loop While c_prima < 85 OrElse Not Lehmann(c_prima)
Return c_prima
End Function
Private Shared Function GCD(a As BigInteger, b As BigInteger) As BigInteger
If a Mod b = 0 Then
Return b
End If
Return GCD(b, a Mod b)
End Function
Universitas Sumatera Utara
86
Private Shared Function generate_tN(p As BigInteger, q As BigInteger) As
BigInteger
Return (p + 1) * (p - 1) * (q + 1) * (q - 1)
End Function
Private Shared Function Lehmann(p As BigInteger) As Boolean
Dim tester As BigInteger, i As BigInteger = 0
'System.Diagnostics.Debug.WriteLine(p, "p");
Do
rng.GetBytes(rnd)
tester = (BitConverter.ToUInt16(rnd, 2) Mod p)
tester = BigInteger.ModPow(tester, (p - 1) / 2, p)
'System.Diagnostics.Debug.WriteLine(tester, "tester");
If tester 1 AndAlso tester - p -1 Then
Return False
End If
'System.Diagnostics.Debug.WriteLine(i, "i");
i += 1
Loop While i < 5
Return True
End Function
Private Shared Function lcm(ParamArray empat As BigInteger()) As BigInteger
Dim hasil As BigInteger = 1
For Each bil As BigInteger In empat
hasil = lcm(hasil, bil)
Next
Return hasil
End Function
Private Shared Function lcm(a As BigInteger, b As BigInteger) As BigInteger
Return CType((a * b) / GCD(a, b), BigInteger)
End Function
Public Shared Function InverseModular(a As BigInteger, b As BigInteger) As
BigInteger
Dim x1 As BigInteger, y1 As BigInteger, x2 As BigInteger, y2 As
BigInteger, q As BigInteger, temp As BigInteger, _
modulo As BigInteger = b
If a < b Then
x1 = InlineAssignHelper(y2, 1)
x2 = InlineAssignHelper(y1, 0)
Else
x1 = InlineAssignHelper(y2, 0)
x2 = InlineAssignHelper(y1, 1)
End If
While b 0
q = a / b
temp = b
b = a - (q * b)
a = temp
temp = x2
x2 = x1 - (q * x2)
x1 = temp
temp = y2
y2 = y1 - (q * y2)
y1 = temp
End While
Return InlineAssignHelper(x1, If(x1 > 0, x1, modulo + x1))
End Function
Universitas Sumatera Utara
87
FormEnk.VB
Public Class EnkripsiForm
'Private Shared luc As lucClass = New lucClass
Private Shared strText As String
Private Shared enkripsiResult As String
Private Shared sb As New StringBuilder()
Private Sub BrowseFileEnkripsiButton_Click(sender As Object, e As
EventArgs) Handles BrowseFileEnkripsiButton.Click
HasilEnkripsiTextBox.Text = ""
SaveFileEnkripsi.Enabled = False
Dim filePath As String
If (OpenFileEnkripsiDialog.ShowDialog = DialogResult.OK) Then
filePath = OpenFileEnkripsiDialog.FileName.ToString
Me.strText = String.Empty
Try
Dim reader As PdfReader = New PdfReader(filePath)
For page As Integer = 1 To reader.NumberOfPages
Dim its As ITextExtractionStrategy = New
iTextSharp.text.pdf.parser.LocationTextExtractionStrategy
Dim s As String = PdfTextExtractor.GetTextFromPage(reader,
page, its)
s =
Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8,
Encoding.Default.GetBytes(s)))
Me.strText = Me.strText + s
Me.strText = Me.strText.Remove(Me.strText.Length - 1, 1)
FileContentEnkripsiTextBox.Text = Me.strText
Next
reader.Close()
EnkripsiButton.Enabled = True
FilePathEnkripsiTextBox.Text = filePath
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End If
End Sub
Private Sub EnkripsiButton_Click(sender As Object, e As EventArgs) Handles
EnkripsiButton.Click
SaveFileEnkripsi.Enabled = True
LUC.hasil_kunci()
Dim time As New System.Diagnostics.Stopwatch()
time.Start()
Tampung.luc_c_kuncia = LUC.enkripsi(FileContentEnkripsiTextBox.Text)
time.Stop()
waktu.Text = time.ElapsedMilliseconds.ToString() & " ms"
pTextBox.Text = LUC.p.ToString()
qTextBox.Text = LUC.q.ToString
nTextBox.Text = LUC.N.ToString
tTextBox.Text = LUC.tN.ToString()
eTextBox.Text = LUC.e.ToString
rnTextBox.Text = LUC.sN.ToString()
dTextBox.Text = LUC.d.ToString
Dim action As New Action(Of BigInteger)(AddressOf hasilenk)
Array.ForEach(Tampung.luc_c_kuncia, action)
Tampung.hasil_enkripsi = EnkripsiForm.sb.ToString()
HasilEnkripsiTextBox.Text = EnkripsiForm.sb.ToString()
Universitas Sumatera Utara
88
End Sub
Private Shared Sub hasilenk(val As BigInteger)
EnkripsiForm.sb.Append(val)
EnkripsiForm.sb.Append("-")
End Sub
Private Sub SaveFileEnkripsi_Click(sender As Object, e As EventArgs)
Handles SaveFileEnkripsi.Click
If SaveFileEnkripsiDialog.ShowDialog = DialogResult.OK Then
Dim path As String = SaveFileEnkripsiDialog.FileName
File.WriteAllText(path, sb.ToString())
'Dim fs As FileStream = File.Create(path)
'Dim info As Byte() = New
UTF8Encoding(True).GetBytes(LUC.d.ToString & " " & LUC.N.ToString & " " &
Me.enkripsiResult)
'fs.Write(info, 0, info.Length)
'fs.Close()
MessageBox.Show("File tersimpan!")
End If
End Sub
Private Sub FileContentEnkripsiTextBox_TextChanged(sender As Object, e As
EventArgs) Handles FileContentEnkripsiTextBox.TextChanged
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs)
End Sub
Private Sub pTextBox_TextChanged(sender As Object, e As EventArgs) Handles
pTextBox.TextChanged
End Sub
Private Sub waktu_TextChanged(sender As Object, e As EventArgs) Handles
waktu.TextChanged
End Sub
EnkripDekrip.VB
Public Shared Function enkripsi(x As String) As BigInteger()
Dim chars As Integer() = pecah_string(x)
Dim new_char As BigInteger() = New BigInteger(chars.Length - 1) {}
Dim i As Integer = 0
For Each c_p As Integer In chars
new_char(i) = barisan_LUC(c_p, 1, e, N)
i += 1
Next
Return new_char
End Function
Public Shared Function dekripsi(enk As BigInteger()) As String
Dim chars As Integer() = New Integer(enk.Length - 1) {}
Dim i As Integer = 0
For Each c_e As BigInteger In enk
chars(i) = CInt(barisan_LUC(c_e, 1, d, N))
i += 1
Universitas Sumatera Utara
89
Next
Return gabung_string(chars)
End Function
Private Shared Function pecah_string(x As String) As Integer()
Dim chars As New List(Of Integer)()
Dim spasi As Char = " "c
Dim batas As Integer = 0, i As Integer = 0
If x.Length Mod 2 = 1 Then
batas = 1
End If
For i = 0 To x.Length - batas - 1 Step 2
Dim x1 As Integer = Math.Abs(Asc(x(i)) - 31)
Dim x2 As Integer = Math.Abs(Asc(x(i + 1)) - 31)
'System.Diagnostics.Debug.WriteLine(x1)
'System.Diagnostics.Debug.WriteLine(x2)
Dim char_gab As String = (x1).ToString() &
(x2).ToString().PadLeft(2, "0"c)
System.Diagnostics.Debug.WriteLine(char_gab)
Dim char_a As Integer = Integer.Parse(char_gab)
chars.Add(char_a)
Next
If batas = 1 Then
Dim char_gab As String = Math.Abs(Asc(x(i)) - 31).ToString() &
(Asc(spasi) - 31).ToString().PadLeft(2, "0"c)
Dim char_a As Integer = Integer.Parse(char_gab)
chars.Add(char_a)
End If
Return chars.ToArray()
End Function
Private Shared Function gabung_string(c_d As Integer()) As String
'int i = 0;
Dim sb As System.Text.StringBuilder = New StringBuilder()
For Each a As Integer In c_d
System.Diagnostics.Debug.WriteLine(a \ 100, "x1 akhir")
System.Diagnostics.Debug.WriteLine(a Mod 100, "x2 akhir")
Dim x1Int As Integer = (a \ 100)
Dim x2Int As Integer = (a Mod 100)
Dim x1 As Char = Chr(If(x1Int = 23 OrElse x1Int = 21, 31 - x1Int,
x1Int + 31))
Dim x2 As Char = Chr(If(x2Int = 23 OrElse x2Int = 21, 31 - x2Int,
x2Int + 31))
sb.Append(x1)
sb.Append(x2)
Next
Return sb.ToString()
End Function
Private Shared Function barisan_LUC(P As BigInteger, Q As BigInteger, e As
BigInteger, N As BigInteger) As BigInteger
Dim Vold As BigInteger = 2
Dim Vnew As BigInteger = P
Dim temp As BigInteger, i As BigInteger = 2
While i 0 Then
Dim cagak As Byte = Convert.ToByte(New
StringBuilder().Append(1).Append("0"c, bitcount).ToString(), 2)
bitbuffer = bitbuffer Or cagak
flag = 1
hasil.Add(bitbuffer)
End If
Return hasil.ToArray()
End Function
Universitas Sumatera Utara
94
Public Shared Function dekompresi(s_values As Byte()) As Byte()
Dim hasil As New List(Of Byte)()
Dim i As Integer = 0
Dim sb As New StringBuilder()
For i = 0 To s_values.Length - 2
sb.Append(Convert.ToString(s_values(i), 2).PadLeft(8, "0"c))
Next
If flag = 1 Then
sb.Append(Convert.ToString(s_values(i), 2).Remove(0, 1))
Else
sb.Append(Convert.ToString(s_values(i), 2).PadLeft(8, "0"c))
End If
decoding(hasil, sb)
Return hasil.ToArray()
End Function
Private Shared Sub decoding(hasil As List(Of Byte), sb As StringBuilder)
Dim bin As New StringBuilder()
Dim n As Integer = 0, i As Integer = 0
While i < sb.Length
If sb(i) = "1"c Then
n += 1
End If
bin.Append(sb(i))
If n = 2 Then
hasil.Add(eg_encoding.FirstOrDefault(Function(x) x.Value =
bin.ToString()).Key)
bin.Clear()
n = 0
End If
i += 1
End While
End Sub
Private
Dim
Dim
For
Shared Function lehmann(i As Integer) As Boolean
a As New Random()
coba As Double = 0
j As Integer = 1 To 10
coba = a.[Next](2, i - 1)
coba = CDbl(BigInteger.ModPow(CType(coba, BigInteger), (i - 1) \ 2,
i))
If coba 1 AndAlso coba - i -1 Then
Return False
End If
Next
Return True
End Function
End Class
FormDekomp.VB
Public Class DekompresiForm
Private Shared sb As New StringBuilder()
Universitas Sumatera Utara
95
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
Tampung.hasil_dekompresi = GoldBach.dekompresi(Tampung.hasil_kompresi)
Dim action As New Action(Of BigInteger)(AddressOf hasilenk)
Array.ForEach(Tampung.luc_c_kuncia, action)
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
System.IO.File.WriteAllText(SaveFileDialog1.FileName,
sb.ToString())
End If
TextBox2.Text =
System.Text.Encoding.Unicode.GetString(Tampung.hasil_dekompresi)
End Sub
Private Shared Sub hasilenk(val As BigInteger)
sb.Append(val)
sb.Append("-")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
TextBox1.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles
Panel1.Paint
End Sub
End Class
Universitas Sumatera Utara
96
DAFTAR RIWAYAT HIDUP
Saya yang bertanda tangan dibawah ini:
DATA PRIBADI
Nama
: Sabrina Ridha Sari Sinaga
Alamat
: Jln. Klambir 5 Gg: Uncu
Email
: [email protected]
Tempat/Tanggal Lahir
: Medan/ 10 Agustus 1992
Jenis Kelamin
: Perempuan
Status
: Belum Menikah
PENDIDIKAN
1998-2004
: SD SWASTA SUPRIYADI MEDAN
2004-2007
: SMP NEGERI 18 MEDAN
2007-2010
: SMA SWASTA DHARMA PANCASILA MEDAN
2010-2013
: DIII-Teknik Informatika Universitas Sumatera Utara
2014-2016
: S1 Ekstensi Ilmu Komputer Universitas Sumatera Utara
SEMINAR
Seminar Nasional Literasi Informasi (SENARAI) Universitas Sumatera Utara
Demikianlah Daftar Riwayat Hidup ini saya buat dengan sebenarnya.
Hormat Saya
Sabrina Ridha
Universitas Sumatera Utara
Listing Program
Pembangkit Kunci.VB
Public NotInheritable Class LUC
Private Sub New()
End Sub
Private Shared rng As New RNGCryptoServiceProvider()
Public Shared e As BigInteger, N As BigInteger, tN As BigInteger, sN As
BigInteger
Public Shared d As BigInteger
Public Shared p As BigInteger, q As BigInteger
'public static BigInteger [] enk_char;
Private Shared rnd As Byte() = New Byte(3) {}
Public Shared Sub hasil_kunci()
Do While p = q
p = generate_bil_prima()
q = generate_bil_prima()
Loop
N = CType(p * q, BigInteger)
tN = generate_tN(p, q)
sN = lcm(New BigInteger() {CType(p, BigInteger) - 1, CType(q,
BigInteger) - 1, CType(p, BigInteger) + 1, CType(q, BigInteger) + 1})
e = must_gdc_with(tN, sN)
d = InverseModular(e, sN)
System.Diagnostics.Debug.WriteLine(GCD(e, sN))
System.Diagnostics.Debug.WriteLine((d * e) Mod sN)
End Sub
Private Shared Function must_gdc_with(p As BigInteger, n As BigInteger) As
UInt16
Dim c_e As UInt16
Do
rng.GetBytes(rnd)
c_e = BitConverter.ToUInt16(rnd, 2)
Loop While GCD(c_e, p) 1 OrElse c_e >= p OrElse c_e >= n
Return c_e
End Function
Private Shared Function generate_bil_prima() As UInt16
Dim c_prima As UInt16
Do
rng.GetBytes(rnd)
c_prima = CType(BitConverter.ToUInt16(rnd, 0) Mod 150, UInt16)
Loop While c_prima < 85 OrElse Not Lehmann(c_prima)
Return c_prima
End Function
Private Shared Function GCD(a As BigInteger, b As BigInteger) As BigInteger
If a Mod b = 0 Then
Return b
End If
Return GCD(b, a Mod b)
End Function
Universitas Sumatera Utara
86
Private Shared Function generate_tN(p As BigInteger, q As BigInteger) As
BigInteger
Return (p + 1) * (p - 1) * (q + 1) * (q - 1)
End Function
Private Shared Function Lehmann(p As BigInteger) As Boolean
Dim tester As BigInteger, i As BigInteger = 0
'System.Diagnostics.Debug.WriteLine(p, "p");
Do
rng.GetBytes(rnd)
tester = (BitConverter.ToUInt16(rnd, 2) Mod p)
tester = BigInteger.ModPow(tester, (p - 1) / 2, p)
'System.Diagnostics.Debug.WriteLine(tester, "tester");
If tester 1 AndAlso tester - p -1 Then
Return False
End If
'System.Diagnostics.Debug.WriteLine(i, "i");
i += 1
Loop While i < 5
Return True
End Function
Private Shared Function lcm(ParamArray empat As BigInteger()) As BigInteger
Dim hasil As BigInteger = 1
For Each bil As BigInteger In empat
hasil = lcm(hasil, bil)
Next
Return hasil
End Function
Private Shared Function lcm(a As BigInteger, b As BigInteger) As BigInteger
Return CType((a * b) / GCD(a, b), BigInteger)
End Function
Public Shared Function InverseModular(a As BigInteger, b As BigInteger) As
BigInteger
Dim x1 As BigInteger, y1 As BigInteger, x2 As BigInteger, y2 As
BigInteger, q As BigInteger, temp As BigInteger, _
modulo As BigInteger = b
If a < b Then
x1 = InlineAssignHelper(y2, 1)
x2 = InlineAssignHelper(y1, 0)
Else
x1 = InlineAssignHelper(y2, 0)
x2 = InlineAssignHelper(y1, 1)
End If
While b 0
q = a / b
temp = b
b = a - (q * b)
a = temp
temp = x2
x2 = x1 - (q * x2)
x1 = temp
temp = y2
y2 = y1 - (q * y2)
y1 = temp
End While
Return InlineAssignHelper(x1, If(x1 > 0, x1, modulo + x1))
End Function
Universitas Sumatera Utara
87
FormEnk.VB
Public Class EnkripsiForm
'Private Shared luc As lucClass = New lucClass
Private Shared strText As String
Private Shared enkripsiResult As String
Private Shared sb As New StringBuilder()
Private Sub BrowseFileEnkripsiButton_Click(sender As Object, e As
EventArgs) Handles BrowseFileEnkripsiButton.Click
HasilEnkripsiTextBox.Text = ""
SaveFileEnkripsi.Enabled = False
Dim filePath As String
If (OpenFileEnkripsiDialog.ShowDialog = DialogResult.OK) Then
filePath = OpenFileEnkripsiDialog.FileName.ToString
Me.strText = String.Empty
Try
Dim reader As PdfReader = New PdfReader(filePath)
For page As Integer = 1 To reader.NumberOfPages
Dim its As ITextExtractionStrategy = New
iTextSharp.text.pdf.parser.LocationTextExtractionStrategy
Dim s As String = PdfTextExtractor.GetTextFromPage(reader,
page, its)
s =
Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8,
Encoding.Default.GetBytes(s)))
Me.strText = Me.strText + s
Me.strText = Me.strText.Remove(Me.strText.Length - 1, 1)
FileContentEnkripsiTextBox.Text = Me.strText
Next
reader.Close()
EnkripsiButton.Enabled = True
FilePathEnkripsiTextBox.Text = filePath
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End If
End Sub
Private Sub EnkripsiButton_Click(sender As Object, e As EventArgs) Handles
EnkripsiButton.Click
SaveFileEnkripsi.Enabled = True
LUC.hasil_kunci()
Dim time As New System.Diagnostics.Stopwatch()
time.Start()
Tampung.luc_c_kuncia = LUC.enkripsi(FileContentEnkripsiTextBox.Text)
time.Stop()
waktu.Text = time.ElapsedMilliseconds.ToString() & " ms"
pTextBox.Text = LUC.p.ToString()
qTextBox.Text = LUC.q.ToString
nTextBox.Text = LUC.N.ToString
tTextBox.Text = LUC.tN.ToString()
eTextBox.Text = LUC.e.ToString
rnTextBox.Text = LUC.sN.ToString()
dTextBox.Text = LUC.d.ToString
Dim action As New Action(Of BigInteger)(AddressOf hasilenk)
Array.ForEach(Tampung.luc_c_kuncia, action)
Tampung.hasil_enkripsi = EnkripsiForm.sb.ToString()
HasilEnkripsiTextBox.Text = EnkripsiForm.sb.ToString()
Universitas Sumatera Utara
88
End Sub
Private Shared Sub hasilenk(val As BigInteger)
EnkripsiForm.sb.Append(val)
EnkripsiForm.sb.Append("-")
End Sub
Private Sub SaveFileEnkripsi_Click(sender As Object, e As EventArgs)
Handles SaveFileEnkripsi.Click
If SaveFileEnkripsiDialog.ShowDialog = DialogResult.OK Then
Dim path As String = SaveFileEnkripsiDialog.FileName
File.WriteAllText(path, sb.ToString())
'Dim fs As FileStream = File.Create(path)
'Dim info As Byte() = New
UTF8Encoding(True).GetBytes(LUC.d.ToString & " " & LUC.N.ToString & " " &
Me.enkripsiResult)
'fs.Write(info, 0, info.Length)
'fs.Close()
MessageBox.Show("File tersimpan!")
End If
End Sub
Private Sub FileContentEnkripsiTextBox_TextChanged(sender As Object, e As
EventArgs) Handles FileContentEnkripsiTextBox.TextChanged
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs)
End Sub
Private Sub pTextBox_TextChanged(sender As Object, e As EventArgs) Handles
pTextBox.TextChanged
End Sub
Private Sub waktu_TextChanged(sender As Object, e As EventArgs) Handles
waktu.TextChanged
End Sub
EnkripDekrip.VB
Public Shared Function enkripsi(x As String) As BigInteger()
Dim chars As Integer() = pecah_string(x)
Dim new_char As BigInteger() = New BigInteger(chars.Length - 1) {}
Dim i As Integer = 0
For Each c_p As Integer In chars
new_char(i) = barisan_LUC(c_p, 1, e, N)
i += 1
Next
Return new_char
End Function
Public Shared Function dekripsi(enk As BigInteger()) As String
Dim chars As Integer() = New Integer(enk.Length - 1) {}
Dim i As Integer = 0
For Each c_e As BigInteger In enk
chars(i) = CInt(barisan_LUC(c_e, 1, d, N))
i += 1
Universitas Sumatera Utara
89
Next
Return gabung_string(chars)
End Function
Private Shared Function pecah_string(x As String) As Integer()
Dim chars As New List(Of Integer)()
Dim spasi As Char = " "c
Dim batas As Integer = 0, i As Integer = 0
If x.Length Mod 2 = 1 Then
batas = 1
End If
For i = 0 To x.Length - batas - 1 Step 2
Dim x1 As Integer = Math.Abs(Asc(x(i)) - 31)
Dim x2 As Integer = Math.Abs(Asc(x(i + 1)) - 31)
'System.Diagnostics.Debug.WriteLine(x1)
'System.Diagnostics.Debug.WriteLine(x2)
Dim char_gab As String = (x1).ToString() &
(x2).ToString().PadLeft(2, "0"c)
System.Diagnostics.Debug.WriteLine(char_gab)
Dim char_a As Integer = Integer.Parse(char_gab)
chars.Add(char_a)
Next
If batas = 1 Then
Dim char_gab As String = Math.Abs(Asc(x(i)) - 31).ToString() &
(Asc(spasi) - 31).ToString().PadLeft(2, "0"c)
Dim char_a As Integer = Integer.Parse(char_gab)
chars.Add(char_a)
End If
Return chars.ToArray()
End Function
Private Shared Function gabung_string(c_d As Integer()) As String
'int i = 0;
Dim sb As System.Text.StringBuilder = New StringBuilder()
For Each a As Integer In c_d
System.Diagnostics.Debug.WriteLine(a \ 100, "x1 akhir")
System.Diagnostics.Debug.WriteLine(a Mod 100, "x2 akhir")
Dim x1Int As Integer = (a \ 100)
Dim x2Int As Integer = (a Mod 100)
Dim x1 As Char = Chr(If(x1Int = 23 OrElse x1Int = 21, 31 - x1Int,
x1Int + 31))
Dim x2 As Char = Chr(If(x2Int = 23 OrElse x2Int = 21, 31 - x2Int,
x2Int + 31))
sb.Append(x1)
sb.Append(x2)
Next
Return sb.ToString()
End Function
Private Shared Function barisan_LUC(P As BigInteger, Q As BigInteger, e As
BigInteger, N As BigInteger) As BigInteger
Dim Vold As BigInteger = 2
Dim Vnew As BigInteger = P
Dim temp As BigInteger, i As BigInteger = 2
While i 0 Then
Dim cagak As Byte = Convert.ToByte(New
StringBuilder().Append(1).Append("0"c, bitcount).ToString(), 2)
bitbuffer = bitbuffer Or cagak
flag = 1
hasil.Add(bitbuffer)
End If
Return hasil.ToArray()
End Function
Universitas Sumatera Utara
94
Public Shared Function dekompresi(s_values As Byte()) As Byte()
Dim hasil As New List(Of Byte)()
Dim i As Integer = 0
Dim sb As New StringBuilder()
For i = 0 To s_values.Length - 2
sb.Append(Convert.ToString(s_values(i), 2).PadLeft(8, "0"c))
Next
If flag = 1 Then
sb.Append(Convert.ToString(s_values(i), 2).Remove(0, 1))
Else
sb.Append(Convert.ToString(s_values(i), 2).PadLeft(8, "0"c))
End If
decoding(hasil, sb)
Return hasil.ToArray()
End Function
Private Shared Sub decoding(hasil As List(Of Byte), sb As StringBuilder)
Dim bin As New StringBuilder()
Dim n As Integer = 0, i As Integer = 0
While i < sb.Length
If sb(i) = "1"c Then
n += 1
End If
bin.Append(sb(i))
If n = 2 Then
hasil.Add(eg_encoding.FirstOrDefault(Function(x) x.Value =
bin.ToString()).Key)
bin.Clear()
n = 0
End If
i += 1
End While
End Sub
Private
Dim
Dim
For
Shared Function lehmann(i As Integer) As Boolean
a As New Random()
coba As Double = 0
j As Integer = 1 To 10
coba = a.[Next](2, i - 1)
coba = CDbl(BigInteger.ModPow(CType(coba, BigInteger), (i - 1) \ 2,
i))
If coba 1 AndAlso coba - i -1 Then
Return False
End If
Next
Return True
End Function
End Class
FormDekomp.VB
Public Class DekompresiForm
Private Shared sb As New StringBuilder()
Universitas Sumatera Utara
95
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
Tampung.hasil_dekompresi = GoldBach.dekompresi(Tampung.hasil_kompresi)
Dim action As New Action(Of BigInteger)(AddressOf hasilenk)
Array.ForEach(Tampung.luc_c_kuncia, action)
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
System.IO.File.WriteAllText(SaveFileDialog1.FileName,
sb.ToString())
End If
TextBox2.Text =
System.Text.Encoding.Unicode.GetString(Tampung.hasil_dekompresi)
End Sub
Private Shared Sub hasilenk(val As BigInteger)
sb.Append(val)
sb.Append("-")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
TextBox1.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles
Panel1.Paint
End Sub
End Class
Universitas Sumatera Utara
96
DAFTAR RIWAYAT HIDUP
Saya yang bertanda tangan dibawah ini:
DATA PRIBADI
Nama
: Sabrina Ridha Sari Sinaga
Alamat
: Jln. Klambir 5 Gg: Uncu
: [email protected]
Tempat/Tanggal Lahir
: Medan/ 10 Agustus 1992
Jenis Kelamin
: Perempuan
Status
: Belum Menikah
PENDIDIKAN
1998-2004
: SD SWASTA SUPRIYADI MEDAN
2004-2007
: SMP NEGERI 18 MEDAN
2007-2010
: SMA SWASTA DHARMA PANCASILA MEDAN
2010-2013
: DIII-Teknik Informatika Universitas Sumatera Utara
2014-2016
: S1 Ekstensi Ilmu Komputer Universitas Sumatera Utara
SEMINAR
Seminar Nasional Literasi Informasi (SENARAI) Universitas Sumatera Utara
Demikianlah Daftar Riwayat Hidup ini saya buat dengan sebenarnya.
Hormat Saya
Sabrina Ridha
Universitas Sumatera Utara