You could also do: f. But the file can still be replaced, therefore the 1st and is more Effective. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Simplest way to encrypt a text file in java Ask Question. Asked 7 years ago. Active 2 years, 4 months ago. Viewed 74k times. I have done some research and many people are recommending DES.
Potentially a way I can create a very simple encryption and decryption algorithm myself? Patch Patch 2 2 gold badges 2 2 silver badges 6 6 bronze badges. The API is a bit verbose, but you can find sample code on this site. Like this one: stackoverflow. A good starting point might be the Java Cryptography Architecture guide [ docs. Consider that password are usually stored with one way function SHA for example.
Are you sure the request is also for decryption? Add a comment. Active Oldest Votes. Try this, Its pretty simple import javax. Cipher; import javax. SecretKeyFactory; import javax. DESedeKeySpec; import org. Improve this answer. This example goes a long way regarding some cryptographic functions, but it fouls up on too many others.
The example is using a String as a key. Furthermore, it silently uses the insecure ECB mode encryption. There is no authenticity or integrity control either. But in general this code is not secure. String can not be converted into byte. In late but why use apache commons for Base Java has base64 built in.
We are using DESede. All the above given steps and concept are same, we just replace algorithms. Base64; import javax. KeyGenerator; import javax. Premraj Premraj Thank you buddy. Can you guide me to some examples of how to use a KeySpec? I will follow all of them. I have recently started commenting on blogs and I guess I have learned lot of things by commenting on blogs and also connected with many bloggers.
How to store encrypted byte to string in database? Vikar, you can Baseencode the encrypted data to turn it into a string. Your email address will not be published. Malhar Lathkar. Anadi Sharma. Tushar Kale. Monica Mittal. Arnab Chakraborty. Java Cryptography - Encrypting Data Advertisements. Previous Page.
0コメント