本文整理汇总了C#中BigNumber.ToHexString方法的典型用法代码示例。如果您正苦于以下问题:C# BigNumber.ToHexString方法的具体用法?C# BigNumber.ToHexString怎么用?C# BigNumber.ToHexString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigNumber
的用法示例。
在下文中一共展示了BigNumber.ToHexString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateRsaPrivateKey
public static RsaKeyPair GenerateRsaPrivateKey(int bits = 2048, BigNumber e = null,
RsaKeyGeneratorCallback cb = null, object cbArg = null)
{
if (e == null)
e = E_F4;
using (var rsa = new RSA())
{
BigNumber.GeneratorHandler cbWrapper = null;
if (cb != null)
cbWrapper = (x,y,z) => cb(x,y,z);
Cipher enc = null;
string pwd = null;
PasswordHandler pwdCb = null;
// If we choose to encrypt:
// Cipher.DES_CBC;
// Cipher.DES_EDE3_CBC;
// Cipher.Idea_CBC;
// Cipher.AES_128_CBC;
// Cipher.AES_192_CBC;
// Cipher.AES_256_CBC;
// and pwd != null || pwdCb != null
// We can use a pwdCb to get a password interactively or we can
// simply pass in a fixed password string (no cbPwd, just pwd)
if (pwd != null)
pwdCb = DefaultPasswordHandler;
// Ref: http://openssl.org/docs/manmaster/crypto/RSA_generate_key_ex.html
rsa.GenerateKeys(bits, e, cbWrapper, cbArg);
using (var bio = BIO.MemoryBuffer())
{
// Ref: http://openssl.org/docs/manmaster/crypto/PEM_write_bio_RSAPrivateKey.html
rsa.WritePrivateKey(bio, enc, pwdCb, pwd);
return new RsaKeyPair(bits, e.ToHexString(), bio.ReadString());
}
}
}