com.mindbright.util
public final class ASCIIArmour extends java.lang.Object
-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,A68BCF5FE86D7652 ZlH6zo6nf8mBxFPGkaUkfXtzgUDTKmUYAUO24eXkoV/fbg+IPOtbPdJa7PKlhQTs 2Ycjb5Gk/ZVwGZaqa01roRSmfGDHL2ZSVrXHHMxDxCn1aU+rOFHcUA== -----END RSA PRIVATE KEY-----
Base64
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_LINE_LENGTH
Default length of encoded lines
|
Constructor and Description |
---|
ASCIIArmour(java.lang.String headerLinePrePostFix)
Creates an instance ready for decoding
|
ASCIIArmour(java.lang.String headerLine,
java.lang.String tailLine)
Creates an instance ready for encoding or decoding
|
ASCIIArmour(java.lang.String headerLine,
java.lang.String tailLine,
boolean blankHeaderSep,
int lineLen)
Creates an instance ready for encoding or decoding
|
Modifier and Type | Method and Description |
---|---|
byte[] |
decode(byte[] data)
Decode the given array.
|
byte[] |
decode(byte[] data,
int offset,
int length)
Decode the given array.
|
byte[] |
decode(java.io.InputStream in)
Decode data from the given InputStream.
|
byte[] |
encode(byte[] data)
Encode data and return the encoded ascii blob
|
byte[] |
encode(byte[] data,
int offset,
int length)
Encode data and return the encoded ascii blob
|
void |
encode(java.io.OutputStream out,
byte[] data)
Encode data and print it to the given OutputStream
|
void |
encode(java.io.OutputStream out,
byte[] data,
int off,
int len)
Encode data and print it to the given OutputStream
|
java.lang.String |
getHeaderField(java.lang.String headerName)
Get one header field
|
java.util.Hashtable<java.lang.String,java.lang.String> |
getHeaderFields()
Get the header fields
|
java.lang.String |
getHeaderLine()
Get the header line
|
java.lang.String |
printHeaders()
Print the header fields to a String.
|
void |
setBlankHeaderSep(boolean value)
Control if a blank line should follow the headers
|
void |
setCanonicalLineEnd(boolean value)
Set if canoncial end of line markings should be used or not
|
void |
setHeaderField(java.lang.String headerName,
java.lang.String value)
Set a header field
|
void |
setHeaderLine(java.lang.String headerLine)
Set the header line
|
void |
setLineLength(int lineLen)
Set length of encoded lines
|
void |
setTailLine(java.lang.String tailLine)
Set the tailing line
|
public static final int DEFAULT_LINE_LENGTH
public ASCIIArmour(java.lang.String headerLine, java.lang.String tailLine, boolean blankHeaderSep, int lineLen)
headerLine
- the first line in the filetailLine
- the last line in the fileblankHeaderSep
- true if a blank line should follow the
header lineslineLen
- maximum length of generated linespublic ASCIIArmour(java.lang.String headerLine, java.lang.String tailLine)
headerLine
- the first line in the filetailLine
- the last line in the filepublic ASCIIArmour(java.lang.String headerLinePrePostFix)
headerLinePrePostFix
- start of header and tail linepublic void setCanonicalLineEnd(boolean value)
value
- true means CRLF which false means LFpublic void setBlankHeaderSep(boolean value)
public void setLineLength(int lineLen)
public java.lang.String getHeaderLine()
public void setHeaderLine(java.lang.String headerLine)
public void setTailLine(java.lang.String tailLine)
public java.util.Hashtable<java.lang.String,java.lang.String> getHeaderFields()
public java.lang.String getHeaderField(java.lang.String headerName)
public void setHeaderField(java.lang.String headerName, java.lang.String value)
public byte[] encode(byte[] data)
data
- the array which will be encodedpublic byte[] encode(byte[] data, int offset, int length)
data
- array in which the data can be foundoffset
- offset in array where data beginslength
- how many bytes the data consists ofpublic void encode(java.io.OutputStream out, byte[] data) throws java.io.IOException
out
- where to send the encoded blobdata
- the array which will be encodedjava.io.IOException
public void encode(java.io.OutputStream out, byte[] data, int off, int len) throws java.io.IOException
out
- where to send the encoded blobdata
- array in which the data can be foundoff
- offset in array where data beginslen
- how many bytes the data consists ofjava.io.IOException
public byte[] decode(byte[] data)
data
- array containg the ascii blob to decodepublic byte[] decode(byte[] data, int offset, int length)
data
- array containg the ascii blob to decodeoffset
- offset in array where data beginslength
- how many bytes the data consists ofpublic byte[] decode(java.io.InputStream in) throws java.io.IOException
in
- stream to read data fromjava.io.IOException
public java.lang.String printHeaders()