Home > pendidikan > Algoritma TEA

Algoritma TEA


Sedikit penjelasan dan contoh perhitungan Enkripsi dan dekripsi Algoritma TEA (Tiny Encryption Algorithm)

TEA

1. Algoritma TEA (Tiny Encryption Algorithm)

TEA memproses 64-bit input dan menghasilkan 64-bit output. 64-bit input disimpan ke dalam L0 dan R0

@32-bit. Sedangkan 128-bit kunci disimpan ke dalam k[0], k[1], k[2], dan k[3] @32-bit. Output-nya disimpan dalam L32 dan R32.

1.a. Algoritma Enkripsi TEA (Tiny Encryption Algorithm)

procedure TeaEncrypt(var data: TLong2; const key: TTeaKey);

var y,z,sum: Longword;

a:byte;

begin

y:=data[0]; z:=data[1]; sum:=0;

for a:=0 to 31 do

begin

inc(sum,Delta);

inc(y,((z shl 4)+key[0]) xor (z+sum) xor ((z shr 5)+key[1]));

inc(z,((y shl 4)+key[2]) xor (y+sum) xor ((y shr 5)+key[3]));

end;

data[0]:=y; data[1]:=z

end;

1.b. Algoritma Dekripsi TEA (Tiny Encryption Algorithm)

procedure TeaDecrypt(var data: TLong2; const key: TTeaKey);

var y,z,sum: Longword;

a:byte;

begin

y:=data[0]; z:=data[1]; sum:=delta shl 5;

for a:=0 to 31 do

begin

dec(z,((y shl 4)+key[2]) xor (y+sum) xor ((y shr 5)+key[3]));

dec(y,((z shl 4)+key[0]) xor (z+sum) xor ((z shr 5)+key[1]));

dec(sum,Delta);

end;

data[0]:=y; data[1]:=z

end;

2.a. Contoh Enkripsi TEA:

Plainteks : SBAA

L0 : SBAA (83-66-65-65)d

Atau (01010011 01000010 01000011 01000011)b

R0 : – – – – (0) d

Atau (00000000 00000000 00000000 00000000)b

Kunci : abc

Key[0] : abc- (97-98-99-0)d

Atau (01100001 01100010 01100011 00000000)b

Key[1] : – – – – (0)d (00000000 00000000 00000000 00000000)b

Key[2] : – – – – (0)d (00000000 00000000 00000000 00000000)b

Key[3] : – – – – (0)d (00000000 00000000 00000000 00000000)b

Round 1 :

SUM = 1 X (2654435770)

L1 = L0 + ( (R0 Shl 4) + K[0] ) XOR ( R0 + SUM ) XOR ( (R0 Shr 5) + K[1] )

L1 = 01010011 01000010 01000011 01000011 + ((00000000 00000000 00000000 00000000 Shl 4) + 01100001

01100010 01100011 00000000) XOR (00000000 00000000 00000000 00000000 + SUM) XOR

((00000000 00000000 00000000 00000000 Shr 5) + 00000000 00000000 00000000 00000000)

L1 = 10110100 10100100 10100100 01000001 (Biner)

L1 = 180 164 164 65 (Decimal)

L1 = ´ ¤ ¤ A (ASCII)

R1 = R0 + ( (L1 Shl 4) + K[2] ) XOR ( L1 + SUM ) XOR ( (L1 Shr 5) + K[3] )

R1 = 00000000 00000000 00000000 00000000 + ( (10110100 10100100 10100100 01000001 Shl 4) + 00000000

00000000 00000000 00000000) XOR (10110100 10100100 10100100 01000001 + SUM) XOR (

(10110100 10100100 10100100 01000001 Shr 5) + 00000000 00000000 00000000 00000000 )

R1 = 01110010 01001011 11011011 11110111 (Biner)

R1 = 114 75 219 247 (Decimal)

R1 = r K Û ÷ (ASCII)

Round 2 :

SUM = 2 X (2654435770)

L2 = L1 + ( (R1 Shl 4) + K[0] ) XOR ( R1 + SUM ) XOR ( (R1 Shr 5) + K[1] )

L2 = 10110100 10100100 10100100 01000001 + ( (01110010 01001011 11011011 11110111 Shl 4) + 01100001

01100010 01100011 00000000) XOR ( 01110010 01001011 11011011 11110111 + SUM) XOR (

(01110010 01001011 11011011 11110111 Shr 5) + 00000000 00000000 00000000 00000000 )

L2 = 11111010 01000100 10011011 00100101 (Biner)

L2 = 250 68 155 37 (Decimal)

L1 = ú D › % (ASCII)

R2 = R1 + ( (L2 Shl 4) + K[2] ) XOR ( L2 + SUM ) XOR ( (L2 Shr 5) + K[3] )

R2 = 01110010 01001011 11011011 11110111 + ( (11111010 01000100 10011011 00100101 Shl 4) + 00000000

00000000 00000000 00000000) XOR (11111010 01000100 10011011 00100101 + SUM) XOR (

(11111010 01000100 10011011 00100101 Shr 5) + 00000000 00000000 00000000 00000000 )

R2 = 100000001 10011000 01101001 01101010 (Biner)

R2 = 129 152 105 106 (Decimal)

6

R2 = • ˜ i j (ASCII)

Penghitungan sampai round 32, akan diperoleh L31 dan R31 ciphertext sebagai berikut:

Ciphertext: Š ð ß Æ ” z š ³ (138 – 240 – 223 – 198 – 34 – 122 – 154 – 179)


2.b. Dekripsi TEA :

Ciphertext : ŠðßÆ”zš³

L0 : ŠðßÆ (138-240-223-198)d (10001010 11110000 11011111 11000110)b

R0 : “zš³ (34-122-154-179)d (00100010 01111010 10011010 10110011)b

Kunci : abc

Key[0] : abc- (97-98-99-0) d (01100001 01100010 01100011 00000000)b

Key[1] : – – – – (0) d (00000000 00000000 00000000 00000000)b

Key[2] : – – – – (0) d (00000000 00000000 00000000 00000000)b

Key[3] : – – – – (0) d (00000000 00000000 00000000 00000000)b

Round 1 :

SUM = 32 X (2654435770)

R1 = R0 – ( (L0 Shl 4) + k[2]) XOR (L0+SUM) XOR ((L0 Shr 5) + k[3]) )

R1 = 00100010 01111010 10011010 10110011 + ( (10001010 11110000 11011111 11000110 Shl 4) + 00000000

00000000 00000000 00000000) XOR (10001010 11110000 11011111 11000110 + SUM ) XOR (

(10001010 11110000 11011111 11000110 Shr 5) + 00000000 00000000 00000000 00000000 )

R1 = 01010100 00100010 10011111 01000111 (Biner)

R1 = 84 34 159 71 (Decimal)

R1 = T » Ÿ G (ASCII)

L1 = L0 – ( (R1 Shl 4) + k[0]) XOR (R1+SUM) XOR ((R1 Shr 5) + k[1]) )

L1 = 10001010 11110000 11011111 11000110 + ( (01010100 00100010 10011111 01000111 Shl 4) + 01100001

01100010 01100011 00000000 ) XOR (01010100 00100010 10011111 01000111 + SUM) XOR (

(01010100 00100010 10011111 01000111 Shr 5) + 00000000 00000000 00000000 00000000 )

L1 = 10111101 10100001 11110000 11011011 (Biner)

L1 = 189 161 240 219 (Decimal)

L1 = ½ ¡ ð Û (ASCII)

Round 2 :

SUM = 31 X (2654435770)

R2 = R1 – ( (L1 Shl 4) + k[2]) XOR (L1+SUM) XOR ((L1 Shr 5) + k[3]) )

R2 = 01010100 00100010 10011111 01000111 + ( (10111101 10100001 11110000 11011011 Shl 4) + 00000000

00000000 00000000 00000000 ) XOR (10111101 10100001 11110000 11011011 + SUM ) XOR (

(10111101 10100001 11110000 11011011 Shr 5) + 00000000 00000000 00000000 00000000 )

R2 = 10011101 11111111 10000010 10011010 (Biner)

R2 = 157 255 130 154 (Decimal)

R2 = • ÿ ‚ š (ASCII)

L2 = L1 – ( (R2 Shl 4) + k[0]) XOR (R2+SUM) XOR ((R2 Shr 5) + k[1]) )

L2 = 10111101 10100001 11110000 11011011 + ( (10011101 11111111 10000010 10011010 Shl 4) + 01100001

01100010 01100011 00000000 ) XOR (10011101 11111111 10000010 10011010 + SUM) XOR (

(10011101 11111111 10000010 10011010 Shr 5) + 00000000 00000000 00000000 00000000 )

L2 = 01011110 11110111 11110001 00011110 (Biner)

L2 = 94 247 241 30 (Decimal)

L2 = ^ ÷ ñ – (ASCII)

Pada akhir penghitungan dekripsi TEA sebanyak 32 round ini diperoleh ciphertext sebagai berikut : “SBAA“.

Categories: pendidikan
  1. November 7, 2013 at 1:27 pm

    ada contoh dgn image ngak

    • tasirmugissae
      November 9, 2013 at 12:29 am

      Screen capture dr app programny y? Bs aj sih mas tp it koleksi lama, jd blm sya cek lg file laporanny, klo dr programny lg gak bs buka, gak ad vb6 nya…

    • tasirmugissae
      November 9, 2013 at 12:31 am

      Screencapture dr app ny? Bs aj sih mas tp blm sya cek lg laporany, mklum it koleksi lama. Klo mau cpture dr app ny lg gak ad vb6 nih…

  2. heri
    November 9, 2013 at 3:44 am

    boleh minta file aplikasi yg bentuk exe’y g mas?

    • tasirmugissae
      November 9, 2013 at 4:22 am

      Klo yg satu bandle sama algoritma lain saya bs ksih th. Tp klo yg khusus tea spt di artikel ini ad laporany jg saya minta fee je mas klo bs… masny mhsiswa ato programer sih?

  3. heri
    November 9, 2013 at 7:33 am

    yang satu bandel sama algoritma ja mas

  4. November 10, 2013 at 1:43 pm

    bisa di bantu ngak gan aplikasi delphi dgn menggunakan input image……
    yg di atas kan buat teks..mohon bantuannya gan….

    • tasirmugissae
      November 11, 2013 at 1:03 am

      Saya pakainy vb6 mas. Itu input fileny bs image jg seinget saya, it koleksi lama saya….

  5. November 10, 2013 at 1:45 pm

    bang tasirmugis boleh minta no penya ngak…..lg butuh bantuan dgn programnya…

    • tasirmugissae
      November 11, 2013 at 1:04 am

      Delphi tdk ad mas… bukany delphi uda gak tll recomend y?

  6. November 12, 2013 at 12:32 am

    jika dgn.vb bisa ngak..’bisa d kirim ngak lewat email data nya….

    • tasirmugissae
      November 12, 2013 at 12:43 am

      Coba kirim emailmu mas….

  7. November 12, 2013 at 12:40 am

    tolong yah gan mohon bimbingan nya….
    jika ada pula yg pake dr app lain selain delphi jg ngak apa2 mas….yg penting source code nya ada.lg butuh mas….
    bisa d kirim k email sy
    lokonnagamas@gmail.com
    makasih mas

    • tasirmugissae
      November 12, 2013 at 12:46 am

      Pindah ke email y mas ngbrolnya….

  8. pram
    November 13, 2013 at 3:06 pm

    mas ada source code java nya ga?

    • tasirmugissae
      November 13, 2013 at 3:10 pm

      Gak puny java mas,,,

  9. November 13, 2013 at 3:08 pm

    iya mas saya juga minta source code lengkap nya ya yg make vb6
    tolong kirim ke rahadian.djati@yahoo.com
    makasih banyak mas

  10. Rram
    January 8, 2014 at 7:32 pm

    Bang bisa email contoh programnya ga?
    kebetulan lagi perlu..
    email saya rrambetuk@gmail.com
    terima kasih

  11. Putri
    August 7, 2015 at 11:58 am

    Mas ada cara penghitungan manual algoritma xxtea ga?

    • tasirmugissae
      August 10, 2015 at 4:03 am

      Artikel saya tea lho bukan xxtea, klo tea program dan pnjelasan coding saya ada.

  12. faizun
    October 4, 2015 at 1:32 am

    ada contoh progamnya gax mas.. lagi butuh banget nih..mohon bantuanya faizunahmad33@gmail.com

  13. March 15, 2016 at 7:17 am

    Gan, ada penjelasaan tentang TEA kaga yang lebih mudah dipahami?

    • tasirmugissae
      June 4, 2016 at 1:59 am

      Sorry om blm sempat ngurusin blog jdvgak kebalas yg pd koment.

  14. anonim
    April 7, 2016 at 11:57 pm

    Mas itu shl4 dan shr5 maksudnya gimana ya??

  15. prasojo bejo
    April 8, 2016 at 12:00 am

    Maksudnya shl4 dan shr5 itu apa ya??

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: