I am trying to encrypt XML using PHP which will be decrypted over java.
While I am doing R&D and i found a code over this link PHP code to decrypt XML encrypted through Java which is doing exactly opposite thing that I am looking for. How can I encrypt XML which comfortably decrypted over java?
It's not a problem to decript a file with diferent language. You just have to implement the same encrypter algorithm and that it's. If you want an asymetric encrypt take a look for RSA, if you want a symetric one look for DES.
Ans sorry but it's all informations you will take on the thread. This site is not a "code on demand" site.
Related
I have an Android application that communicates with another java application. For the data encryption i use the javax.crypto library to encrypt and decrypt the data with a pre-shared key.
According to this question it's possible to get the source code from an APK file. So if somebody is able to read the source code of my application, he's also able to read/manipulate the encrypted data.
It's probably true, so is there a way to prevent this (additional measures, other security method)? Don't know if it have extra value but here is my encryption code:
private static String IV = "AAAAAAAAAAAAAAAA";
private static String ENCRYPTION_KEY = "0123456789abcdef";
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
SecretKeySpec key = new SecretKeySpec(ENCRYPTION_KEY.getBytes("UTF-8"), "AES");
cipher.init(Cipher.ENCRYPT_MODE, key,new IvParameterSpec(IV.getBytes("UTF-8")));
return cipher.doFinal(input.getBytes("UTF-8"));
EDIT:
Communication is send and recieving by NFC. My main issue is, if someone has the key he's able to read and write (abused) information to the other side (the NFC reader)
The pre-shared key is not safe!
For someone with just little java reverse engineering skills it is a job of five minutes to decompile your APK file and extracting the key. Once this has been done your crypto is effectively useless.
The standard approach to fix this is to use a key agreement algorithm. You can for example use the Diffie-Hellman key exchange to quickly and secure generate a common secret between two devices: Wikipedia on Diffie-Hellman
Build a hash from the generated common secret and use this as your AES encryption key for this session is a lot more secure and doesn't take much work.
If NFC is your transport layer you need bidirectional data exchanges for Diffie-Hellman to work. Therefore Android Beam will not be usable for you. You can however do bidirectinal data-transfer using host based card emulation on one phone and reader/writer mode on the other.
Using encryption when transmitting data over NFC is a good idea by the way, also the communication range is limited to some few centimeters, you can still sniff the communication from a few meters distance. NFC doesn't do any encryption for you.
A last word of warning: Cryptography is hard to do in practice. Before you send out anything of value over a cryptographic link please make sure that you have a good understanding of what you do. I recommend reading this book which is a good and practical introduction of cryptography: Bruce Schneider - Cryptography Engineering
I need to encrypt and decrypt a text file.For encryption and decryption i may use DES/AES algorithms.I have a code for encrypt and decrypt text file but the problem is,the first line in file must be encrypted in such a way it should be understandable.using AES and DES iam getting non readable format after encryption.I need to read the first line of file after encryption.Please help me .Thanks in advance
Why not add a user-readable magic number to the beginning of the file, and again after you're done with the text block? Something like this:
MagiKrypt
This file has been encrypted with MagiKrypt, and you will need the program at (URL HERE) to decrypt it.
MakiKrypt\x00\x01\x02\x03
(AES data here)
EOF
This way your program would easily be able to tell where is text, and where is AES data, and the user would be able to read the first part of the file. It would still be a mess if they open it in a text editor, but at least they'd see the intro block.
Encryption produces bytes, not human readable characters. To make your bytes human readable, you need to convert them to a different format. I would suggest Base64 as a common way to do this.
After you have encrypted your file, convert as much of it as you need to Base64 and display the Base64 part. It will not make any sense, but it won't contain anything too weird.
Its better to keep unecrypted the first line or you should cerate rules of your own and encrypt the first(and all) text.Its better to use SHAI algorithm for better encryptions.Other than SHA1 another choice is BTE encryption
I would like to encrypt a file using a symmetric key and decrypt it using the game key in java without losing data, I tried an encryption of a 56 byte file and the resultant file was 10 bytes which makes me think I'm going wrong somewhere.
Are there any tutorials on how to encrypt and decrypt files in java using a symmetric key? (and how to get said key?)
Here is a short nice tutorial: http://www.javamex.com/tutorials/cryptography/symmetric.shtml
Here is a related question: Java using AES 256 and 128 Symmetric-key encryption
Hope it'll help.
I have a vector of user passwords. I would like to save this vector to a file and encrypt it. Then load and decrypt the file to get the passwords. I would like my users to enter a pass phrase to decrypt the files. Which algorithm should i choose? and How can i encrypt the vector before writing the file?
Encryption in Java is done using the Java Cryptography Architecture (doc contains example code). As for which algorithm to use, AES should be fine.
However, don't use Vector - it's utterly outdated and should be replaced with ArrayList (this has nothing to do with cryptography, but using Vector marks you as someone who's been learning Java from 12 year old books).
I think you can checkout my other post (example included) and get a headstart.
few characters missing after decryption
Basically you just need to use CipherInputStream & CipherOutputStream, and that's it! :)
Hi I have created my rsa public key in java and send to my friend.
My friend is using IPhone, he encrypted data with that key and send me the decrypted data then I decrypted the data with my private key.
But I am getting errors for Bad Padding.
I and my friend both did not use any padding explicitly for RSA.
Thanks
Bapi
your question is unclear
it was decrypted twice?
editing for your edit:
you're still wrong, you may want to read up on how public key cryptography works before asking questions about your specific implementation. it sounds like you are very unfamiliar with the process