本文整理汇总了C++中bigint::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ bigint::resize方法的具体用法?C++ bigint::resize怎么用?C++ bigint::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bigint
的用法示例。
在下文中一共展示了bigint::resize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
rsa2_error rsa2_write_keys(bigint n, bigint d, bigint e, unsigned int bits, char *base)
{
char pubkeyfile[1024], privkeyfile[1024];
unsigned char *obuf;
FILE *pubkey, *privkey;
sprintf(pubkeyfile, "%s.pub", base);
sprintf(privkeyfile, "%s.pri", base);
if ((pubkey = fopen(pubkeyfile, "wb")) == NULL)
return RSA2_FILE_ERR;
if ((privkey = fopen(privkeyfile, "wb")) != NULL)
{
n.resize(bits);
d.resize(bits);
e.resize(bits);
obuf = n.getdata();
fwrite(obuf, bits, 1, pubkey);
fwrite(obuf, bits, 1, privkey);
free(obuf);
obuf = e.getdata();
fwrite(obuf, bits, 1, pubkey);
free(obuf);
obuf = d.getdata();
fwrite(obuf, bits, 1, privkey);
free(obuf);
fflush(pubkey);
fflush(privkey);
fclose(pubkey);
fclose(privkey);
return RSA2_NO_ERR;
}
fclose(pubkey);
return RSA2_FILE_ERR;
}
示例2: divmod
inline void divmod(const bigint &a,int b,bigint &div,int &mod){
div.resize(a.size());
long long l=0;
for(int i=a.size()-1;i>=0;--i){
l*=BASE;
l+=a[i];
div[i]=l/b;
l%=b;
}
if(div[div.size()-1]==0 and div.size()>1)
div.resize(div.size()-2);
mod=int(l);
}
示例3: multiply
void multiply(bigint &x, bigint &y, bigint &z) {
z.resize(x.size() + y.size(), 0);
for (int i = 0; i < x.size(); i++) {
for (int j = 0; j < y.size(); j++) {
z[i+j] += x[i] * y[j];
z[i+j+1] += z[i+j]/10;
z[i+j] = z[i+j]%10;
}
}
}
示例4: doresize
void doresize(bigint &ret, const bigint &lhs, const bigint &rhs)
{
unsigned int size = rhs.getWidth() > lhs.getWidth() ? rhs.getWidth() : lhs.getWidth();
if (ret.getWidth() < size)
ret.resize(size);
}