⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 derinteger.java

📁 进行与数字证书相关开发必须的java源码
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   DERInteger.java

package jit.asn1;

import java.io.IOException;
import jit.math.BigInteger;

// Referenced classes of package jit.asn1:
//            DERObject, ASN1OctetString, ASN1TaggedObject, DEROutputStream

public class DERInteger extends DERObject
{

    byte bytes[];

    public static DERInteger getInstance(Object obj)
    {
        if(obj == null || (obj instanceof DERInteger))
            return (DERInteger)obj;
        if(obj instanceof ASN1OctetString)
            return new DERInteger(((ASN1OctetString)obj).getOctets());
        if(obj instanceof ASN1TaggedObject)
            return getInstance(((ASN1TaggedObject)obj).getObject());
        else
            throw new IllegalArgumentException("illegal object in getInstance: ".concat(String.valueOf(String.valueOf(obj.getClass().getName()))));
    }

    public static DERInteger getInstance(ASN1TaggedObject obj, boolean explicit)
    {
        return getInstance(obj.getObject());
    }

    public DERInteger(int value)
    {
        bytes = BigInteger.valueOf(value).toByteArray();
    }

    public DERInteger(BigInteger value)
    {
        bytes = value.toByteArray();
    }

    public DERInteger(byte bytes[])
    {
        this.bytes = bytes;
    }

    public BigInteger getValue()
    {
        return new BigInteger(bytes);
    }

    public BigInteger getPositiveValue()
    {
        return new BigInteger(1, bytes);
    }

    void encode(DEROutputStream out)
        throws IOException
    {
        out.writeEncoded(2, bytes);
    }

    public int hashCode()
    {
        int value = 0;
        for(int i = 0; i != bytes.length; i++)
            value ^= (bytes[i] & 0xff) << i % 4;

        return value;
    }

    public boolean equals(Object o)
    {
        if(o == null || !(o instanceof DERInteger))
            return false;
        DERInteger other = (DERInteger)o;
        if(bytes.length != other.bytes.length)
            return false;
        for(int i = 0; i != bytes.length; i++)
            if(bytes[i] != other.bytes[i])
                return false;

        return true;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -