简体   繁体   English

如何使用openssl和php创建小型公共/专用密钥?

[英]How to create small public/private keys using openssl and php?

I need to create a public/private key, but I don't need big keys, I try to use the follow code: 我需要创建一个公共/私有密钥,但是我不需要大密钥,我尝试使用以下代码:

<?php
$config = array('private_key_bits' => 128);
$res = openssl_pkey_new($config);
?>

but I get this warning: 但我得到这个警告:

Warning: openssl_pkey_new(): private key length is too short; it needs to be at least 384 bits, not 64

Do I have to change something? 我需要改变一些东西吗? (config files, modules etc etc?) (配置文件,模块等?)

Upgraded to answer: 升级回答:

as I didnt know (I'm well away from web development currently!) I looked up the size limits on a cookie and they are 4kb each and you can create upto 20 per domain you should have space for a 1024 bit key even if you do have to use a dictionary lookup system between the cookies. 正如我所不知道的那样(我目前还很远离Web开发!)我在cookie上查找了大小限制,每个大小限制为4kb,每个域最多可以创建20个限制,即使您有1024位密钥,也应该有空间确实必须在Cookie之间使用字典查找系统。

Also please make sure that the private key is sent using an ssl connection otherwise someone can intercept the private key and all your work will have been in vain 另外,请确保使用ssl连接发送私钥,否则有人可以截获私钥,并且您的所有工作都将徒劳无功

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM