Example #1
0
        public string ToString(string format)
        {
            if (fDisposed)
            {
                throw new ObjectDisposedException("this");
            }

            IntPtr str = IntPtr.Zero;

            if (format.ToLower() == "d")
            {
                str = OpenSSL.BN_bn2dec(fBigNum);
            }
            else if (format.ToLower() == "x")
            {
                str = OpenSSL.BN_bn2hex(fBigNum);
            }
            else
            {
                throw new FormatException();
            }

            string res = Marshal.PtrToStringAnsi(str);

            OpenSSL.CRYPTO_free(str);
            return(res);
        }