1

I am currently study on AES, There are several good site explaining and giving example about AES Encryption in java such as this. Example show AES encrypt String into byte.

My question is how to convert application such as exe, txt and mp3? I understand i have to convert the application into byte before encryption can be implement but how do you achieve that?

The SO here and here explain about encrypt executable file but does not answer my question.

Community
  • 1
  • 1
Ridzuan Adris
  • 1,192
  • 2
  • 13
  • 32
  • I think the answer is obvious, i state it myself. I just have to find the right code to read and convert files to byte and do the encryption from there. i suppose i have to delete this post. – Ridzuan Adris Mar 31 '14 at 03:54
  • Instead of deleting your post, answer it yourself. There's no penalty for that, as long as you are explicit in your answer. – avgvstvs Mar 31 '14 at 04:10

3 Answers3

2

You should look into https://community.oracle.com/thread/2152253 link

Also refer How to read content of .EXE file in Java

Community
  • 1
  • 1
Balwinder Singh
  • 2,272
  • 5
  • 23
  • 34
  • 1
    Instead of deleting the post, you can post your final answer. This might help someone else in future. – Balwinder Singh Mar 31 '14 at 04:17
  • 1
    @BalwinderSingh You should not just use links in your answer, Balwinder Singh. At least give a general description of what is said in the links, if only because links may become unavailable (if you would have been linking to sun.com, then it would already have become unavailable, to name just one reason). – Maarten Bodewes Mar 31 '14 at 20:18
  • @owlstead Thanks for the tip. I am new to this community. Will be using this tip in future communication will all here. – Balwinder Singh Apr 01 '14 at 03:32
2

FileInputStream reads files into byte arrays.

user207421
  • 305,947
  • 44
  • 307
  • 483
0

You may use NIO2 for random access files. This will represent the file data with a ByteBuffer. This is generally more efficient than using streams. The Java encryption classes happily accommodate you by supplying encryption methods on ByteBuffer - update and doFinal specifically.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263