public final class PlainText extends Object implements Serializable
Strings. Once constructed, this
object is immutable.
Note: Conversion to/from UTF-8 byte-encoding can, in theory, throw
an UnsupportedEncodingException. However, UTF-8 encoding
should be a standard encoding for all Java installations, so an
UnsupportedEncodingException never actually be thrown. Therefore,
in order to to keep client code uncluttered, any possible
UnsupportedEncodingExceptions will be first logged, and then
re-thrown as a RuntimeException with the original
UnsupportedEncodingException as the cause.
Copyright © 2009 - The OWASP Foundation
CipherText,
Serialized Form| Constructor and Description |
|---|
PlainText(byte[] b)
Construct a
PlainText object from a byte array. |
PlainText(String str)
Construct a
PlainText object from a String. |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
asBytes()
Convert the
PlainText object to a byte array. |
protected boolean |
canEqual(Object other)
Needed for correct definition of equals for general classes.
|
boolean |
equals(Object anObject) |
int |
hashCode()
Same as
this.toString().hashCode(). |
int |
length()
Return the length of the UTF-8 encoded byte array representing this
object.
|
void |
overwrite()
First overwrite the bytes of plaintext with the character '*'.
|
String |
toString()
Convert the
PlainText object to a UTF-8 encoded String. |
public PlainText(String str)
PlainText object from a String.str - The String that is converted to a UTF-8 encoded
byte array to create the PlainText object.IllegalArgumentException - If str argument is null.public PlainText(byte[] b)
PlainText object from a byte array.b - The byte array used to create the PlainText
object.public String toString()
PlainText object to a UTF-8 encoded String.public byte[] asBytes()
PlainText object to a byte array.PlainText object.public int hashCode()
this.toString().hashCode().public int length()
PlainText(String str), then this length might not necessarily
agree with str.length().public void overwrite()
protected boolean canEqual(Object other)
See How to write an Equality Method in Java for full explanation.
Copyright © 2016 The Open Web Application Security Project (OWASP). All rights reserved.