deroctetstring.java
来自「《移动Agent技术》一书的所有章节源代码。」· Java 代码 · 共 98 行
JAVA
98 行
package org.bouncycastle.asn1;import java.io.*;public class DEROctetString extends DERObject{ byte[] string; /** * @param string the octets making up the octet string. */ public DEROctetString( byte[] string) { this.string = string; } public DEROctetString( DERObject obj) { try { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); DEROutputStream dOut = new DEROutputStream(bOut); dOut.writeObject(obj); dOut.close(); this.string = bOut.toByteArray(); } catch (IOException e) { throw new IllegalArgumentException("Error processing object : " + e.toString()); } } public DEROctetString( DEREncodable obj) { this(obj.getDERObject()); } public byte[] getOctets() { return string; } void encode( DEROutputStream out) throws IOException { out.writeEncoded(OCTET_STRING, string); } public int hashCode() { byte[] b = this.getOctets(); int value = 0; for (int i = 0; i != b.length; i++) { value ^= (b[i] & 0xff) << (i % 4); } return value; } public boolean equals( Object o) { if (o == null || !(o instanceof DEROctetString)) { return false; } DEROctetString other = (DEROctetString)o; if (other.getOctets().length != this.getOctets().length) { return false; } byte[] b1 = other.getOctets(); byte[] b2 = this.getOctets(); for (int i = 0; i != b1.length; i++) { if (b1[i] != b2[i]) { return false; } } return true; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?