Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
3Activity
0 of .
Results for:
No results containing your search query
P. 1
التشفير بالجافا

التشفير بالجافا

Ratings: (0)|Views: 263 |Likes:
Published by Majed Jemmieh
تشفير المعلومات باستخدام لغة الجافا java
Java Encryption
تشفير المعلومات باستخدام لغة الجافا java
Java Encryption

More info:

Categories:Topics, Art & Design
Published by: Majed Jemmieh on Sep 01, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

06/19/2014

pdf

text

original

 
 1mjemmjeh@hotmail.com 
م
.
 ﺔﯾﻣﺟﻟا دﺟﺎﻣ
2010-08-27
ﺎﻓﺎﺟﻟﺎﺑ رﯾﻔﺷﺗﻟا مادﺧﺗﺳا
 
 ﺗ ﺷ ﻔ ﯾرا ﻟ ﻣ ﻌ ﻠو ﻣﺎت ﺑﺎ ﺳ ﺗ ﺧدام ﻟ ﻐﺔ
 java
 
ﺔﻣدﻘﻣ
:
نﻣ نﻛﻣﺗﻧ ﻰﺗﺣ رﻣﻷا ئدﺎﺑ ﻲﻓ ﺗرﻔﺷيأفﻠﻣﮫﻠﺳرأوفرطﻠﻟﻲﻧﺎﺛﻟامزﻻنوﻛﯾيدﻧﻋحﺎﺗﻔﻣاذھوحﺎﺗﻔﻣﻟامزﻻ نوﻛﯾ ﺳﻓدﻧﻋفرطﻟاﻲﻧﺎﺛﻟا ﻲﻧﻌﯾ
 
لﯾﺧﺗدﺟوﯾ ﮫﻧا ﻲﻌﻣقودﻧﺻﮫﯾﻓ تﻌﺿووتﺎﻣوﻠﻌﻣ ﺗﻠﻔﻗوتﺎﻣوﻠﻌﻣﻟا كﻠﺗ ﻰﻟإ لوﺻوﻟا نﻣ دﺣأ نﻛﻣﺗﯾ ﻻ ﻲﻛ نﻵاوفرطﻟاﻲﻧﺎﺛﻟاضرﺗﻔﻣﻟا نﻣنوﻛﯾدﻧﻋهسﻔﻧحﺎﺗﻔﻣﻟاﻰﺗﺣنﻣ نﻛﻣﺗﯾﺢﺗﻓقودﻧﺻﻟاﮫﻧﻣ تﺎﻣوﻠﻌﻣﻟا ذﺧأو
 
لوﺄﻓةوطﺧﻲھدﯾﻟوﺗحﺎﺗﻔﻣﻟا وھو مادﺧﺗﺳﻼﻟ زھﺎﺟ فﺻ ﺎﻧﯾطﻌﺗ نﺄﺑ ﺎﻓﺎﺟ ﺎﻧﻧﻛﻣﺗ
KeyGenerator
موﻘﯾ ثﯾﺣءﺎﺷﻧﺈﺑﺔﯾﻣزراوﺧ بﺳﺣ حﺎﺗﻔﻣطﯾﺳوﻟﺎﺑ ةررﻣﻣﻟا رﯾﻔﺷﺗﻟاﮫﻣﺳا فﺻ ﻲﻧﺑﻧﺳ
SecurityClass
ﻲﻠﯾ ﺎﻣ بﺗﻛﻧﺳ ﮫﯾﻧﺎﺑ نﻣﺿو
public SecurityClass() {try {k = KeyGenerator.getInstance("DES");
 ھﺎﻧ ط ﻠ ﺑ ﻧﺎحﺎﺗﻔﻣاذھحﺎﺗﻔﻣﻟا ﻟ ﻧمدﺧﺗﺳﺔﯾﻣزراوﺧ ـﻟا
 DESkk = k.generateKey();
 ھ ﻧﺎأ ﻧ ﺷ ﺄ ﻧﺎحﺎﺗﻔﻣﻟاوﺢﺑﺻأوھ
KK} catch (NoSuchAlgorithmException ex) {}}
 
ﺔظﺣﻼﻣ
:
حﺎﺗﻔﻣﻟا سﻔﻧ دﻟوﯾ نأ دﺣأ ﻊﯾطﺗﺳﯾ ﻻو دﻘﻌﻣ نوﻛﯾ حﺎﺗﻔﻣ دﯾﻟوﺗ نﻋ ﺔﻟوؤﺳﻣﻟا ﻲھ رﯾﻔﺷﺗﻟا ﺔﯾﻣزراوﺧ نإﺔﯾﻣزراوﺧو لﻣﺟﻟا ﺔﯾﻣزراوﺧ ﺔﻣدﺧﺗﺳﻣﻟا تﺎﯾﻣزراوﺧﻟا نﻣ ، حﺎﺗﻔﻣﻟا دﯾﻟوﺗ ﺔﯾﻠﻣﻋ ﻲﻓ ةدﻘﻌﻣ تﺎﯾﻠﻣﻋ ﻊﺑﺗﺗ ﺎﮭﻧﻷ
DES
ىرﺧأ تﺎﯾﻣزراوﺧ كﺎﻧھو
 
 
 2mjemmjeh@hotmail.com 
م
.
 ﺔﯾﻣﺟﻟا دﺟﺎﻣ
2010-08-27
ﺎﻓﺎﺟﻟﺎﺑ رﯾﻔﺷﺗﻟا مادﺧﺗﺳا
 
رﯾﻔﺷﺗﻟا ﺔﯾﻠﻣﻌﺑ موﻘﯾ يذﻟا ﻊﺑﺎﺗﻟا بﺗﻛﻧﺳ نﻵاو
public static void encrypt() throws Exception {Cipher c = Cipher.getInstance("DES/ECB/PKCS5Padding");
 ھ ﻧﺎ ط ﻠ ﺑ ﻧﺎﺔﯾﻣزراوﺧرﯾﻔﺷﺗﻟا ﺎﻌﺑطوﻲھمزﻻنوﻛﺗسﻔﻧﺔﯾﻣزراوﺧﻟاﻲﻠﯾﺎﮭﺗﻣدﺧﺗﺳاﻲﻓدﯾﻟوﺗحﺎﺗﻔﻣﻟا
 
نﺣﻧجﺎﺗﺣﻧﺔﯾﻣزراوﺧﻠﻟرﯾﻔﺷﺗﻟا ﻧ ﻲﻛرﻔﺷتﺎﻣوﻠﻌﻣﻟاﺎﮭﻌﺿو دﯾرﻧ ﻲﺗﻟالﺧادﺑقودﻧﺻﻟا
 
c.init(Cipher.ENCRYPT_MODE, kk);
 ھ ﻧﺎ
 
 ﺋﯾھ ﻧﺎضرﻐﻟايذﻟا ﻧر ﯾدنأ ﻧﮫﻣدﺧﺗﺳﻲﻓﺔﯾﻠﻣﻋرﯾﻔﺷﺗﻟا حﺎﺗﻔﻣﻟﺎﺑيذﻟادﻟو ﻧﺎهﻲﻓﻲﻧﺎﺑﻟا ﺋﯾھو ﻧﺎضرﻐﻟاﻲﻛنوﻛﯾﻲﻓﻊﺿورﯾﻔﺷﺗﻟا
 
 ھ ﻧﺎ طﻘﻓ ﺧأذ ﻧﺎضﺑﻘﻣنﻋفﻠﻣﻟايذﻟا ﻧنأ دﯾر ﻧرﻔﺷهوھو
exam.xmlBufferedReader inS = new BufferedReader(newFileReader("hp://localhost:8080/test/exam.xml"));
 ھﺎﻧأرﻗ ﻧﺎرطﺳدﺣاو طﻘﻓنﻣفﻠﻣﻟا ﻧزﺧوﺎهلوﺣﺗﻣﻟﺎﺑ
temp
 
String temp = inS.readLine();
 
 ھلﺧدﯾﺳ ﺎﻧ ﻘﻠﺣﺑﺔﻰﺗﺣﺢﺑﺻﯾلوﺣﺗﻣﻟا
temp
غرﺎﻓ
while (temp != null) {byte[] arg0 = temp.getBytes();
 ﻟوﺣﺎﻧرطﺳﻟايذﻟاأرﻗ ﻧﺎهﻰﻟإتﯾﺎﺑ
 arg0 = c.doFinal(arg0);
 ھﺎﻧتﺎﺗﺎﺑﻟاﺔﺟﺗﺎﻧﻟاﺎھﺎﻧﻠﺧدأﻰﻟإﺔﯾﻣزراوﺧﻟاﻲھوﺎﮭﺳﻔﻧﺑرﻔﺷﺗﺳمھﻊﺟرﺗو ﺎﻧﻟﺞﺗﺎﻧرﯾﻔﺷﺗﻟا
 
لوﺣﺗﻣﻟا لﺧاد ﺔﻧزﺧﻣ ةرﻔﺷﻣ تﺎﻣوﻠﻌﻣ يدﻟ ﺢﺑﺻأ نﻵاو
arg0b.write(new String(arg0) + "\n");
 ھوﺎﻧ طﻘﻓﻰﻠﻋ ةرﻔﺷﻣﻟا تﺎﻣوﻠﻌﻣﻟا ﺎﻧﺑﺗﻛفﻠﻣمھﺎﻧﻌﺿو يأ لﺧادﺑقودﻧﺻﻟا
 
 
 3mjemmjeh@hotmail.com 
م
.
 ﺔﯾﻣﺟﻟا دﺟﺎﻣ
2010-08-27
ﺎﻓﺎﺟﻟﺎﺑ رﯾﻔﺷﺗﻟا مادﺧﺗﺳا
 
temp = inS.readLine();
 ھوﺎﻧﺎﻌﺑطمزﻻأرﻗارطﺳﻟاﻲﻧﺎﺛﻟانﻣفﻠﻣﻟاهرﻔﺷﻧ ﻲﻛ
 }
رﺧأ فﻠﻣ ﻰﻠﻋ ﺎﮭﺗﺑﺎﺗﻛو ﺎھرﯾﻔﺷﺗ ﻊﻣ روطﺳﻟا لﻛ ةءارﻗ دﻌﺑ ﺔﻘﻠﺣﻟا نﻣ جرﺧﻧﺳ
b.close();}
اذﻛھو
 
 ﻧنوﻛﺎﻧﺻﻠﺧنﻣﺔﻟادﻟارﯾﻔﺷﺗﻟا
 
أدﺑﻧﺳ نﻵاو ﺑﺔﻟادكﻓرﯾﻔﺷﺗﻟا ﺔﻟادﻟا هذھ مدﺧﺗﺳﯾ فوﺳ رﺧﻷا فرطﻟا نﺄﺑ ﺎﻧھو
public static void decrypt() throws Exception {
ﺎﻧھﺔﯾﻟﻵاﺎﮭﺳﻔﻧ،و ﺑﺎ ﻟ ﺗﺎ ﻟﻲا ﻟ ﻐرض ﻧددﺣﮫﻟعوﻧﺔﯾﻣزراوﺧﻟاو ﻧﮫﺋﯾﮭحﺎﺗﻔﻣﻟﺎﺑيذﻟا ﯾنوﻛ ﻧ ﻧﺳﻔنﯾﺑ كرﺗﺷﻣ ﮫ نﯾﻓرطﻟا
 Cipher c = Cipher.getInstance("DES/ECB/PKCS5Padding");c.init(Cipher.DECRYPT_MODE, kk);
ا ﻧ ﺗ ﺑنوھحﺎﺗﻔﻣﻟا ﺳﻔﻧ
kk
 ظﺣﻼﻣﺔ
:
رﯾﻔﺷﺗﻟا كﻔﻟ مدﺧﺗﺳﯾﻟ ضرﻐﻟا ﺎﻧﺋﯾھ ﺎﻧھ
 
ﺎﻧھوﺎﻧذﺧأضﺑﻘﻣنﻋفﻠﻣﻟارﻔﺷﻣﻟا
 
BufferedReader b = new BufferedReader(new FileReader("hp://localhost:8080/test/encrypted.dat"));
 
ﺎﻧھوﺎﻧذﺧأضﺑﻘﻣنﻋفﻠﻣﻟادﯾرﻧ يذﻟانأ ﻧبﺗﻛﮫﯾﻠﻋتﺎﻣوﻠﻣﻟادﻌﺑكﻓرﯾﻔﺷﺗﻟا
BufferedWriter bb = new BufferedWriter(newFileWriter("hp://localhost:8080/test/exam.xml"));
 

Activity (3)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
Saddam Housien liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->