使用OpenSSL生成素数 [英] Generate prime number using OpenSSL

查看:443
本文介绍了使用OpenSSL生成素数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用openssl生成一个大的随机素数,我发现了如何生成一个随机数并检查它是否为素数,但是我无法自动化检查素数的过程,这是我的命令正在使用:openssl rand -hex 256 | xargs openssl prime -hex

How can I generate a large random prime using openssl, I found out how to generate a random number and check if it is prime but I have not been able to automate the process of checking the primality, here is the command that i am using: openssl rand -hex 256 | xargs openssl prime -hex

是否应该使用 while循环重复检查结果是否为质数?如何自动检查结果是否不包含关键字"not",

Should I use a while loop to repeatedly check if the result is prime? How can I automate the process of checking if the result does not contain the keyword "not",

这是我编写while循环的全部内容:

This is all the further i got on writing the while loop:

while [{openssl rand -hex 256 | xargs openssl prime -hex} = *"$not"*]

推荐答案

OpenSSL版本1.0.0及更高版本将-generate选项添加到prime命令:

OpenSSL version 1.0.0 and newer adds -generate option to the prime command:

$ openssl prime -generate -bits 2048 -hex
D668FDB1968891AE5D858E641B79C4BA18ABEF8C571CBE004EA5673FB3089961E4670681B794063592124D13FF553BBD5CCC81106A9E5F7D87370DD5DA6342B1DAC13CD2E584759CDEC3E76AEFB799848E48EA9C218F53FE3103E1081B8154AD41DDCB931175853FE3D433CECD886B4D94C211EAE01AE5EA93F8FBD6812A9DEF0308378EE963B3C39F80865BA0E1D957683F4ED77ADA9812091AA42E9A56F43C37185223FF9E3DD03C312E71DED072E5686873B3CA6F5F575C569FB0A10CFEA17D7FEB898A8A02549FF6E4B7A1FBCE78656D3DCF227318EEEF8E601C23AA32DF41A61F04D39FC752F70A809D636238340B7B929F0CDBA629F7DE6AAAC44D2BA5

这篇关于使用OpenSSL生成素数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆