Java Reference
In-Depth Information
The following step enters the code for the verifyFormat() method of the
Password class.
To Code the verifyFormat() Private Helper Method
1. Enter the code in lines 198 through 219 as shown in Figure 9-36 on the
previous page.
TextPad displays the helper method, verifyFormat(), for the Password class
(Figure 9-37). This method has private access, limiting its use to methods
within the Password class.
throws general
exception if
password not
within size limits
access is
private; limited
to this class
throws general
exception if password
not provided
helper method
verifies format
of entered
password
FIGURE 9-37
throws general
exception if password
contains no numeric
character
throws general
exception if
password not
within size limits
The encrypt() Method
The encrypt() method is responsible for encrypting the given password value
according to the algorithm provided in the requirements document. Many tech-
niques exist to perform the process of encryption , which is the conversion of
data into a form not understood easily by unauthorized users. Some of these
encryption techniques include substitution of letters and numbers or the rota-
tion of letters in the alphabet. Encrypted data is called ciphertext , as opposed to
unencrypted data, which is called plaintext . The process of converting ciphertext
into plaintext is called decryption .
The algorithm used in the Password class is used primarily to illustrate
certain String and StringBuffer methods. Additionally, the hash code used to
make the encrypted value unique may not always provide a consistent result,
depending on the implementation. Consequently, this code should not be used
as a basis for providing secure and reliable encryption.
 
Search WWH ::




Custom Search