Encryption 用Maple实现Fermat攻击
我正在尝试在maple中实施Fermat攻击,但它给了我一个错误,指出Encryption 用Maple实现Fermat攻击,encryption,cryptography,maple,prime-factoring,Encryption,Cryptography,Maple,Prime Factoring,我正在尝试在maple中实施Fermat攻击,但它给了我一个错误,指出错误,(意外的)。maple的超级初学者,因此如果有经验的人能够提供帮助,将不胜感激 还有,我正在尝试计算一个125位长的整数。有人知道Maple或其他程序中有什么有效的算法可以处理和计算如此大的整数吗 FermatAtttack:=proc(n::And(posint,odd), maxnumsteps::posint:=10^7,(numsteps::truefalse:=false)) local x, k, r, i,
错误,
(意外的)。maple的超级初学者,因此如果有经验的人能够提供帮助,将不胜感激
还有,我正在尝试计算一个125位长的整数。有人知道Maple或其他程序中有什么有效的算法可以处理和计算如此大的整数吗
FermatAtttack:=proc(n::And(posint,odd), maxnumsteps::posint:=10^7,(numsteps::truefalse:=false))
local x, k, r, i, y:
x:=isqrt(n);
if x^2 < n then
x:= x+1
end if;
k:=2*x+1;
r:=x^2-n;
for i to maxnumsteps while not issqr(r) do
r:=r+k;
k:=k+2
end do;
if issqr(r) then
x:=(k-1)/2;
y:=isqrt(r)
else
error "%1 could not facot in %2 iteratioons", n, maxnumsteps
end if;
if not numsteps then
x-y, x+y
else
x-y, x+y, i
end if;
end proc:
fermatattack:=proc(n::And(posint,奇数),maxnumsteps::posint:=10^7,(numsteps::truefalse:=false))
局部x,k,r,i,y:
x:=isqrt(n);
如果x^2
您需要使用数字字段筛选来计算125位整数的因子。请参阅开始。错误消息是一个简单的语法错误。您的第一行可能是
FermatAtttack:=proc(n::And(posint,odd), maxnumsteps::posint:=10^7,{numsteps::truefalse:=false})
Maple使用命令“ifactor”对整数进行因子运算。在过程定义的参数序列FermatAttack
中,括号内的参数声明中有一个圆括号内的项,因此会显示错误消息
(numsteps::truefalse:=false)
将其更改为:
numsteps::truefalse:=false
或者
{numsteps::truefalse:=false}
根据您打算如何调用它。第二个被称为关键字参数。下面是一个简短的区别说明
FA := proc( ns::truefalse:=false )
print(ns);
end proc:
FA();
false
FA(true);
true
FB := proc( {ns::truefalse:=false} )
print(ns);
end proc:
FB(); # getting the default value
false
FB( ns=false );
false
FB( ns=true );
true
FB( ns ); # a convenience of type truefalse keyword parameters
true
如果使用关键字参数方法,请注意下一个示例中传递的参数true
与关键字不匹配(因此得到其默认值)
FB( true );
false