|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.owasp.esapi.crypto.PlainText
public final class PlainText
A class representing plaintext (versus ciphertext) as related to
cryptographic systems. This class embodies UTF-8 byte-encoding to
translate between byte arrays and String
s. 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
UnsupportedEncodingException
s 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 FormConstructor Summary | |
---|---|
PlainText(byte[] b)
Construct a PlainText object from a byte array. |
|
PlainText(java.lang.String str)
Construct a PlainText object from a String . |
Method Summary | |
---|---|
byte[] |
asBytes()
Convert the PlainText object to a byte array. |
protected boolean |
canEqual(java.lang.Object other)
Needed for correct definition of equals for general classes. |
boolean |
equals(java.lang.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 '*'. |
java.lang.String |
toString()
Convert the PlainText object to a UTF-8 encoded String . |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PlainText(java.lang.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.public PlainText(byte[] b)
PlainText
object from a byte
array.
b
- The byte
array used to create the PlainText
object.Method Detail |
---|
public java.lang.String toString()
PlainText
object to a UTF-8 encoded String
.
toString
in class java.lang.Object
String
representing the PlainText
object.public byte[] asBytes()
PlainText
object to a byte array.
PlainText
object.public boolean equals(java.lang.Object anObject)
equals
in class java.lang.Object
public int hashCode()
this.toString().hashCode()
.
hashCode
in class java.lang.Object
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(java.lang.Object other)
See http://www.artima.com/lejava/articles/equality.html
for full explanation.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |