代码1Word下载.docx

上传人:b****5 文档编号:18681268 上传时间:2022-12-31 格式:DOCX 页数:99 大小:36.12KB
下载 相关 举报
代码1Word下载.docx_第1页
第1页 / 共99页
代码1Word下载.docx_第2页
第2页 / 共99页
代码1Word下载.docx_第3页
第3页 / 共99页
代码1Word下载.docx_第4页
第4页 / 共99页
代码1Word下载.docx_第5页
第5页 / 共99页
点击查看更多>>
下载资源
资源描述

代码1Word下载.docx

《代码1Word下载.docx》由会员分享,可在线阅读,更多相关《代码1Word下载.docx(99页珍藏版)》请在冰豆网上搜索。

代码1Word下载.docx

protectedfinalintlineLength;

privatefinalintchunkSeparatorLength;

protectedBaseNCodec(intunencodedBlockSize,intencodedBlockSize,intlineLength,intchunkSeparatorLength)

{

this(unencodedBlockSize,encodedBlockSize,lineLength,chunkSeparatorLength,(byte)61);

}

protectedBaseNCodec(intunencodedBlockSize,intencodedBlockSize,intlineLength,intchunkSeparatorLength,bytepad)

this.unencodedBlockSize=unencodedBlockSize;

this.encodedBlockSize=encodedBlockSize;

booleanuseChunking=(lineLength>

0)&

&

(chunkSeparatorLength>

0);

this.lineLength=(useChunking?

lineLength/encodedBlockSize*encodedBlockSize:

this.chunkSeparatorLength=chunkSeparatorLength;

this.pad=pad;

booleanhasData(Contextcontext)

returncontext.buffer!

=null;

intavailable(Contextcontext)

=null?

context.pos-context.readPos:

0;

protectedintgetDefaultBufferSize()

return8192;

privatebyte[]resizeBuffer(Contextcontext)

if(context.buffer==null){

context.buffer=newbyte[getDefaultBufferSize()];

context.pos=0;

context.readPos=0;

}else{

byte[]b=newbyte[context.buffer.length*2];

System.arraycopy(context.buffer,0,b,0,context.buffer.length);

context.buffer=b;

returncontext.buffer;

protectedbyte[]ensureBufferSize(intsize,Contextcontext)

if((context.buffer==null)||(context.buffer.length<

context.pos+size)){

returnresizeBuffer(context);

intreadResults(byte[]b,intbPos,intbAvail,Contextcontext)

if(context.buffer!

=null){

intlen=Math.min(available(context),bAvail);

System.arraycopy(context.buffer,context.readPos,b,bPos,len);

context.readPos+=len;

if(context.readPos>

=context.pos){

context.buffer=null;

returnlen;

returncontext.eof?

-1:

returnfalse;

publicObjectencode(Objectobj)

throwsEncoderException

if(!

(objinstanceofbyte[])){

thrownewEncoderException("

ParametersuppliedtoBase-Nencodeisnotabyte[]"

);

returnencode((byte[])obj);

publicStringencodeToString(byte[]pArray)

returnStringUtils.newStringUtf8(encode(pArray));

publicStringencodeAsString(byte[]pArray)

publicObjectdecode(Objectobj)

throwsDecoderException

if((objinstanceofbyte[]))

returndecode((byte[])obj);

if((objinstanceofString)){

returndecode((String)obj);

thrownewDecoderException("

ParametersuppliedtoBase-Ndecodeisnotabyte[]oraString"

publicbyte[]decode(StringpArray)

returndecode(StringUtils.getBytesUtf8(pArray));

publicbyte[]decode(byte[]pArray)

if((pArray==null)||(pArray.length==0)){

returnpArray;

Contextcontext=newContext();

decode(pArray,0,pArray.length,context);

decode(pArray,0,-1,context);

byte[]result=newbyte[context.pos];

readResults(result,0,result.length,context);

returnresult;

publicbyte[]encode(byte[]pArray)

encode(pArray,0,pArray.length,context);

encode(pArray,0,-1,context);

byte[]buf=newbyte[context.pos-context.readPos];

readResults(buf,0,buf.length,context);

returnbuf;

abstractvoidencode(byte[]paramArrayOfByte,intparamInt1,intparamInt2,ContextparamContext);

abstractvoiddecode(byte[]paramArrayOfByte,intparamInt1,intparamInt2,ContextparamContext);

protectedabstractbooleanisInAlphabet(byteparamByte);

publicbooleanisInAlphabet(byte[]arrayOctet,booleanallowWSPad)

for(inti=0;

i<

arrayOctet.length;

i++){

if((!

isInAlphabet(arrayOctet[i]))&

((!

allowWSPad)||((arrayOctet[i]!

=this.pad)&

(!

isWhiteSpace(arrayOctet[i])))))

returntrue;

publicbooleanisInAlphabet(Stringbasen)

returnisInAlphabet(StringUtils.getBytesUtf8(basen),true);

protectedbooleancontainsAlphabetOrPad(byte[]arrayOctet)

if(arrayOctet==null){

for(byteelement:

arrayOctet){

if((this.pad==element)||(isInAlphabet(element))){

publiclonggetEncodedLength(byte[]pArray)

longlen=(pArray.length+this.unencodedBlockSize-1)/this.unencodedBlockSize*this.encodedBlockSize;

if(this.lineLength>

0)

len+=(len+this.lineLength-1L)/this.lineLength*this.chunkSeparatorLength;

staticclassContext

intibitWorkArea;

longlbitWorkArea;

byte[]buffer;

intpos;

intreadPos;

booleaneof;

intcurrentLinePos;

intmodulus;

publicStringtoString()

returnString.format("

%s[buffer=%s,currentLinePos=%s,eof=%s,ibitWorkArea=%s,lbitWorkArea=%s,modulus=%s,pos=%s,readPos=%s]"

newObject[]{getClass().getSimpleName(),Arrays.toString(this.buffer),Integer.valueOf(this.currentLinePos),Boolean.valueOf(this.eof),Integer.valueOf(this.ibitWorkArea),Long.valueOf(this.lbitWorkArea),Integer.valueOf(this.modulus),Integer.valueOf(this.pos),Integer.valueOf(this.readPos)});

}

packagemons.codec.digest;

importjava.io.IOException;

importjava.io.InputStream;

importjava.security.MessageDigest;

importjava.security.NoSuchAlgorithmException;

importmons.codec.binary.Hex;

importmons.codec.binary.StringUtils;

publicclassDigestUtils

privatestaticfinalintSTREAM_BUFFER_LENGTH=1024;

privatestaticbyte[]digest(MessageDigestdigest,InputStreamdata)

throwsIOException

returnupdateDigest(digest,data).digest();

publicstaticMessageDigestgetDigest(Stringalgorithm)

try

returnMessageDigest.getInstance(algorithm);

}catch(NoSuchAlgorithmExceptione){

thrownewIllegalArgumentException(e);

publicstaticMessageDigestgetMd2Digest()

returngetDigest("

MD2"

publicstaticMessageDigestgetMd5Digest()

MD5"

publicstaticMessageDigestgetSha1Digest()

SHA-1"

publicstaticMessageDigestgetSha256Digest()

SHA-256"

publicstaticMessageDigestgetSha384Digest()

SHA-384"

publicstaticMessageDigestgetSha512Digest()

SHA-512"

publicstaticMessageDigestgetShaDigest()

returngetSha1Digest();

publicstaticbyte[]md2(byte[]data)

returngetMd2Digest().digest(data);

publicstaticbyte[]md2(InputStreamdata)

returndigest(getMd2Digest(),data);

publicstaticbyte[]md2(Stringdata)

returnmd2(StringUtils.getBytesUtf8(data));

publicstaticStringmd2Hex(byte[]data)

returnHex.encodeHexString(md2(data));

publicstaticStringmd2Hex(InputStreamdata)

publicstaticStringmd2Hex(Stringdata)

publicstaticbyte[]md5(byte[]data)

returngetMd5Digest().digest(data);

publicstaticbyte[]md5(InputStreamdata)

returndigest(getMd5Digest(),data);

publicstaticbyte[]md5(Stringdata)

returnmd5(StringUtils.getBytesUtf8(data));

publicstaticStringmd5Hex(byte[]data)

returnHex.encodeHexString(md5(data));

publicstaticStringmd5Hex(InputStreamdata)

publicstaticStringmd5Hex(Stringdata)

publicstaticbyte[]sha(byte[]data)

returnsha1(data);

publicstaticbyte[]sha(InputStreamdata)

publicstaticbyte[]sha(Stringdata)

publicstaticbyte[]sha1(byte[]data)

returngetSha1Digest().digest(data);

publicstaticbyte[]sha1(InputStreamdata)

returndigest(getSha1Digest(),data);

publicstaticbyte[]sha1(Stringdata)

returnsha1(StringUtils.getBytesUtf8(data));

publicstaticStringsha1Hex(byte[]data)

returnHex.encodeHexString(sha1(data));

publicstaticStringsha1Hex(InputStreamdata)

publicstaticStringsha1Hex(Stringdata)

publicstaticbyte[]sha256(byte[]data)

returngetSha256Digest().digest(data);

publicstaticbyte[]sha256(InputStreamdata)

returndigest(getSha256Digest(),data);

publicstaticbyte[]sha256(Stringdata)

returnsha256(StringUtils.getBytesUtf8(data));

publicstaticStringsha256Hex(byte[]data)

returnHex.encodeHexString(sha256(data));

publicstaticStringsha256Hex(InputStreamdata)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1