الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

التشفير

بدأه وردة الوردات في 13 أكتوبر 2010 · 12 رد · 1,790 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

أرجو من الاخوة الأعزاء عدم حذف الموضوع

أريد ارشادي في فك التشفير باستخدام الجافا

انا استخدم NetBeans 6.8

وعندي ملف جاهز ومفتاح جهاز واريد استخدام هذا الملف و هذا المفتاح بلغة الجافا وفك تشفير هذا الملف باستخدام هذا المفتاح وتخزين الملف الاصلي (بعد فك التشفير) على

هيئة ملف ورد أو notepad

باستخدام تقنية AES

هل احتاج الى package معينة اضيفها

#3
// Test AES Encryption and Decryption using JCrypto

// usage :
// java AESTest -gen KeyFile
// java AESTest -enc PlainFile CipherFile KeyFile
// java AESTest -dec CipherFile plainFile KeyFile

import com.sudancs.jcrypto.AESCipher ;
import com.sudancs.jFile.FileOperations ;

import java.security.Key ;
import java.io.IOException ;

public class AESTest {
   public static void main (String[] args ) {
      if ( args.length > 0 ) {
         try {
            if ( args[0].equals("-gen") ) {
               AESCipher AES = new AESCipher("AES");
               Key key = AES.getKey();
               FileOperations.writeKeyToDisk( args[1] , key );
            }
            else if ( args[0].equals("-enc") ) {
               Key key = FileOperations.readKeyFromDisk( args[3] );       // read key file
               AESCipher AES = new AESCipher("AES",key);
               byte[] plainText  = FileOperations.readFromDisk( args[1] ) ; // read plain File
               byte[] cipherText = AES.encrypt(plainText) ; 
               FileOperations.writeToDisk( args[2] , cipherText ) ;       // write cipher file
            }
            else if ( args[0].equals("-dec") ) {
               Key key = FileOperations.readKeyFromDisk( args[3] );        // read key file
               AESCipher AES = new AESCipher("AES",key);
               byte[] cipherText  = FileOperations.readFromDisk( args[1] ) ; // read cipher File
               byte[] plainText = AES.decrypt(cipherText) ; 
               FileOperations.writeToDisk( args[2] , plainText ) ;            // write plain file
            }
         }
         catch ( Exception ioe ) {
            ioe.printStackTrace();
         }
      }
      else
         System.out.println("error in usage");
   }
}

لعمل ما تريد ، قم بتشغيل البرنامج بالمعاملات:

java AESTest -dec CipherFile plainFile KeyFile

وغير CipherFile باسم الملف المشفر ، وplainFile باسم الملف الجديد الناتج ، و KeyFile بالمفتاح لديك

البرنامج يستخدم مكتبة JCrypto كتبت فوق مكتبة التشفير في جافا (Just Wrapper). وهي موجودة بالمرفقات،،

بالتوفيق،

Test_JCrypto v1.0.rar

http://informatic-ar.com منصة تعليمية عربية في علوم الحاسب والبرمجة

https://moalfat.com  للكتب الالكترونية والكورسات التعليمية

Everything we see now is just an engineering solution based on old science

#4

جزاك الله الف خير وجعلها في ميزان حسناتك

ولكن أخي الكريم كيف اضع هذا المرفق مع ملف الجافا

وهل اعمل ملف جافا نوعه application not class

لان مطلوب مني :

AES-128 to decrypt a message

The program should be named "decrypt" and should accept 3-command line arguments as follows:

decrypt cipher_file key_file target_file

what mean command line arguments and how to use ??????????

Use "ECB" for encryption mode and "PKCS5PADDING" for the padding.

#5

السلام عليكم

عزيزي وضعت الكود واضفت المكتبة للبرنامج ولكن سأخبرك ما حصل معي

I create java application and from source page add new java class

then i copy code and put it here but problem here :

import java.io.IOException ;

يضع تحتها خط ما ادري فين المشكلة شي اخر كيف اشغل البرنامج بالمعاملات لم افهم

#6
وردة الوردات كتب:

السلام عليكم

عزيزي وضعت الكود واضفت المكتبة للبرنامج ولكن سأخبرك ما حصل معي

I create java application and from source page add new java class

then i copy code and put it here but problem here :

import java.io.IOException ;

يضع تحتها خط ما ادري فين المشكلة شي اخر كيف اشغل البرنامج بالمعاملات لم افهم

وعليكم السلام ورحمه الله وبركاته

لو تحتها خط اصفر فهى تدل على انهامكتبه اضافيه غير مستخدمه فى كودك

انما ان كانت احمر فهناك شىء خطأ

ساعتها ممكن ترفق الكود ونشوف ايه المشكله

بالتوفيق:)

Software Developer
Mahmoudkelany.com


 

#7

جاوبوني جزاكم الله خير

أستخدمت شاشة الدوس لتشغيل برنامج جافا بحيث كتبت البرنامج على هيئة ملف نصي ولكن لم استطع اضافة المكتبة المرفقة كيف ذلك اضيفها على الجافا في شاشة الدوس ارجوكم جاوبوني

#8

أيضا لدي سؤال اخر وهو :

trying to write a program that uses "brute force" to decrypt an encrypted message (using AES), where I only have the first 96-bits of the 128-bit secret key

then program run in command line called program findk

like this :

findk cipher_file key_file

The program should print out on standard output the missing 4 bytes of the key in hexadecimal, the decrypted message and the time it took to find the correct key.

#9

To compile your .java file that uses "JCrypto" lib use this command

javac File.java -cp ./lib/JCrypt.jar

^

(for example).

#10

ارجوكم ساعدوني في مشكلة مع هذا الكود :

// Test AES Encryption and Decryption using JCrypto

// usage :

// java AESTest -gen KeyFile

// java AESTest -enc PlainFile CipherFile KeyFile

// java AESTest -dec CipherFile plainFile KeyFile

import com.sudancs.jcrypto.AESCipher ;

import com.sudancs.jFile.FileOperations ;

import java.security.Key ;

import java.io.IOException ;

public class AESTest {

public static void main (String[] args ) {

if ( args.length > 0 ) {

try {

if ( args[0].equals("-gen") ) {

AESCipher AES = new AESCipher("AES");

Key key = AES.getKey();

FileOperations.writeKeyToDisk( args[1] , key );

}

else if ( args[0].equals("-enc") ) {

Key key = FileOperations.readKeyFromDisk( args[3] ); // read key file

AESCipher AES = new AESCipher("AES",key);

byte[] plainText = FileOperations.readFromDisk( args[1] ) ; // read plain File

byte[] cipherText = AES.encrypt(plainText) ;

FileOperations.writeToDisk( args[2] , cipherText ) ; // write cipher file

}

else if ( args[0].equals("-dec") ) {

Key key = FileOperations.readKeyFromDisk( args[3] ); // read key file

AESCipher AES = new AESCipher("AES",key);

byte[] cipherText = FileOperations.readFromDisk( args[1] ) ; // read cipher File

byte[] plainText = AES.decrypt(cipherText) ;

FileOperations.writeToDisk( args[2] , plainText ) ; // write plain file

}

}

catch ( Exception ioe ) {

ioe.printStackTrace();

}

}

else

System.out.println("error in usage");

}

}

عندما اشغله من الدوس يظهر لي

exception in thread main.........

علما بان ملف المفتاح + ciphere

من نوع .dat

ومطلوب مني أن يكون

AES-128 to decrypt a message

Use "ECB" for encryption and decreption mode and "PKCS5PADDING" for the padding.

#11

تأكد من ترجمة البرنامج (اكتب الأمر من سطر الأوامر):

javac -cp lib\JCrypt.jar AESTest.java

ولتشغيل البرنامج، يمكنك استخدام أي من الاوامر التالية:

java -cp .;lib\JCrypt.jar AESTest -gen MyKey.AES

java -cp .;lib\JCrypt.jar AESTest -enc PT.txt C.DAT MyKey.AES

java -cp .;lib\JCrypt.jar AESTest -dec C.DAT O.TXT MyKey.AES

الأول يستخدم لتوليد مفتاح اسمه MyKey.AES ، والثاني لتشفير ملف اسمه PT.TXT والناتج سوف يكون في ملف جديد باسم C.DAT بالمفتاح MyKey.AES ، والأخير لفك التشفير ،، غير اسماء هذه الملفات على حسب ما تريد،

بالنسبة للexception فقم بطابعته كاملاًـ

بالتوفيق.

http://informatic-ar.com منصة تعليمية عربية في علوم الحاسب والبرمجة

https://moalfat.com  للكتب الالكترونية والكورسات التعليمية

Everything we see now is just an engineering solution based on old science

#12

عملت نفس الخطوات مع العلم ان ملف المفتاح عندي من نوع key.dat

ولكن يظهر عندي خطأ وهو :

: invalid stream header java.io.streamcorruptedException

مع العلم انه مطلوب مني :

AES-128 to decrypt a message

Use "ECB" for encryption and decreption mode and "PKCS5PADDING" for the padding

#13

how can I solve this problem

Exception in thread "main" java.lang.NoClassDefFoundError: [ClassName]

مواضيع مشابهة