Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Java Workshop

You're reading from   The Java Workshop Learn object-oriented programming and kickstart your career in software development

Arrow left icon
Product type Paperback
Published in Oct 2019
Publisher Packt
ISBN-13 9781838986698
Length 606 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Eric Foster-Johnson Eric Foster-Johnson
Author Profile Icon Eric Foster-Johnson
Eric Foster-Johnson
Andreas Göransson Andreas Göransson
Author Profile Icon Andreas Göransson
Andreas Göransson
David Cuartielles David Cuartielles
Author Profile Icon David Cuartielles
David Cuartielles
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Getting Started FREE CHAPTER 2. Learning the Basics 3. Object-Oriented Programming 4. Collections, Lists and Java's Built-In APIs 5. Exceptions 6. Libraries, Packages, and Modules 7. Databases and JDBC 8. Sockets, Files, and Streams 9. Working with HTTP 10. Encryption 11. Processes 12. Regular Expressions 13. Functional Programming with Lambda Expressions 14. Recursion 15. Processing Data with Streams 16. Predicates and Other Functional Interfaces 17. Reactive Programming with Java Flow 18. Unit Testing Appendix

Encrypting Files

Encrypting files is very much like encrypting strings. However, with large files, it may be wise to empty the cipher streams. However, if the file is too large, or if there are multiple files, then it may be wise to apply CipherStreams—not to be confused with Stream Cipher.

CipherStreams inherit most of their behavior from InputStream and OutputStream of Java, with the modification that you can decrypt a file you read, or encrypt a file you write with the supplied cipher.

Exercise 3: Encrypting a File

The following exercise displays how to encrypt a file. You can find this file in the code repository.

  1. Open the Chapter10 project in IDEA if it's not already open.
  2. Create a new Java class, using the File | New | Java Class menu.
  3. Enter Exercise3 as Name, and then select OK. You should now have an empty class in your project:
    package com.packt.java.chapter10;
    public class Exercise3 {
    }
  4. Add a main method in which you'll write the...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image