openssl系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html


1.1 openssl speed

测试加密算法的性能。

支持的算法有:

openssl speed [md2] [mdc2] [md5] [hmac] [sha1] [rmd160] [idea-cbc] [rc2-cbc] [rc5-cbc] [bf-cbc] [des-cbc] [des-ede3] [rc4] [rsa512] [rsa1024] [rsa2048] [rsa4096] [dsa512] [dsa1024] [dsa2048] [idea] [rc2] [des] [rsa] [blowfish]

不过为什么没有base64算法呢?

测试速度好几秒一个指标,很慢。如果不指定参数将测试所有支持的算法,所以会花很久时间,我的虚拟机上花了十多分钟才测试完所有的算法性能。

例如测试下,dsa512、rsa512和rsa2048加密速度如何。

[root@xuexi tmp]# openssl speed dsa512 rsa512 rsa2048
Doing bit private rsa's for 10s: 107496 512 bit private RSA's in .99s
Doing bit public rsa's for 10s: 1425095 512 bit public RSA's in .00s
Doing bit private rsa's for 10s: 4623 2048 bit private RSA's in .99s
Doing bit public rsa's for 10s: 153395 2048 bit public RSA's in .99s
Doing bit sign dsa's for 10s: 102089 512 bit DSA signs in 10.00s
Doing bit verify dsa's for 10s: 121654 512 bit DSA verify in 9.99s
sign verify sign/s verify/s
rsa bits .000093s .000007s 10760.4 142509.5
rsa bits .002161s .000065s 462.8 15354.9
sign verify sign/s verify/s
dsa bits .000098s .000082s 10208.9 12177.6

在10秒时间内,rsa512的私钥处理107496单位,而rsa2048仅处理4623单位,慢了20多倍。

再看签名性能,dsa算法只支持签名不支持加密,而rsa支持加密也支持签名。从上面的结果中可以看到rsa512的签名速度为每秒10760.4,而dsa512的速度为10208.9,速度相差不大。

1.2 openssl rand

生成伪随机数。

openssl rand [-out file] [-rand file(s)] [-base64] [-hex] num

选项说明:

-out:指定随机数输出文件,否则输出到标准输出。

-rand file:指定随机数种子文件。种子文件中的字符越随机,openssl rand生成随机数的速度越快,随机度越高。

-base64:指定生成的随机数的编码格式为base64。

-hex:指定生成的随机数的编码格式为hex。

num:指定随机数的长度。

示例:

[root@xuexi tmp]# openssl rand -base64 ;openssl rand -hex ;openssl rand
7Nsce908GnQ5vpDH7Ww44f5ayZxCI0C9MzxSuaLj
af3efb867af2ffa7b9fd2ebd8caa977fc8d26f8a01de86d7b3de8630a25e
=@oxW[root@xuexi tmp]#

可以看到,不指定-base64或-hex时生成的随机数是乱码随机数(其实是2进制),且没有\n符号。

openssl speed和openssl rand的更多相关文章

  1. 3.openssl speed和openssl rand

    (1).openssl speed 测试加密算法的性能. 支持的算法有: openssl speed [md2] [mdc2] [md5] [hmac] [sha1] [rmd160] [idea-c ...

  2. (5) openssl speed(测试算法性能)和openssl rand(生成随机数)

    1.1 openssl speed 测试加密算法的性能 支持的算法有: openssl speed [md2] [mdc2] [md5] [hmac] [sha1] [rmd160] [idea-cb ...

  3. Openssl speed命令

    一.简介 speed命令用于测试库的性能 二.语法 openssl speed [md2] [mdc2] [md5] [hmac] [sha1] [sha256] [sha512] [whirlpoo ...

  4. php开启openssl的方法,openssl安装

    php开启openssl的方法,openssl安装 2014年10月10日 8312次浏览 什么是openssl? 关于openssl,我说的不如百度百科齐全,还是看看百度百科的解释吧!http:// ...

  5. OpenSSL主配置文件openssl.cnf

    虽说配置文件很多设置不用修改就能直接使用,但是了解它是配置openssl相关事项所必须的.而且要实现复杂多功能,必然要对配置相关了然于心. 1.man config 该帮助文档说明了openssl.c ...

  6. (12) OpenSSL主配置文件openssl.cnf

    1.man config 该帮助文档说明了openssl.cnf以及一些其他辅助配置文件的规范.格式及读取方式.后文中的所有解释除非特别指明,都将以openssl.cnf为例. [root@local ...

  7. 6.openssl rsautl和openssl pkeyutl

    rsautl是rsa的工具,相当于rsa.dgst的部分功能集合.可用于签名.验证.加密和解密文件.非对称密钥的密钥是随机生成的,因此不需要也无法指定salt参与加密. pkeyutl是非对称加密的通 ...

  8. ambari2.6.50 openssl 版本问题:SSLError: Failed to connect. Please check openssl library versions. Openssl error upon host registration

    I'm trying to register hostnames in Ambari but getting the error below. We tried to run yum update o ...

  9. 【openssl】利用openssl完成X509证书和PFX证书之间的互转

    利用openssl完成X509证书和PFX证书之间的互转 # OpenSSL的下载与安装: 1.下载地址: 官方网址—— https://www.openssl.org/source/ OpenSSL ...

随机推荐

  1. Unity的几个特殊文件夹

    1.以.开头的文件夹会被unity忽略,资源不会被导入,脚本不会编译. 2.Standard Assets和Pro Standard Assets:在这个文件夹中的脚本最先被编译. 3.Editor: ...

  2. ABP框架系列之二十二:(Dynamic-Web-API-动态WebApi)

    Building Dynamic Web API Controllers This document is for ASP.NET Web API. If you're interested in A ...

  3. PostgreSQL和MySQL

    PostgreSQL分布式

  4. Mysql中比较常用的两种存储引擎和事务

    存储引擎:引擎(类似汽车上的发动机)决定了数据库的快慢,MySql中有20多个引擎,不同的存储引擎提供不同的存储机制.索引技巧.锁定水平.MYISAM存储引擎,INNODB存储引擎最出名.数据库的核心 ...

  5. Do More With These Great Plugins for Windows Live Writer(old)

    This article is out of day,now we use open live wirter, but we don’t have so much works great plugin ...

  6. Java RMI 使用例子

    1.创建协议接口(UserService) /** * */ package com.junge.demo.rmi.protocol.service; import java.io.Serializa ...

  7. Centos系统安装InfluxDB

    概述安装influxDB时需要root用户或者管理员权限. 端口默认情况下,InfluxDB会使用如下的端口: * TCP8086端口是服务器监听端口,对HTTP API响应 * TCP8088端口是 ...

  8. 8. Filters in ASP.NET MVC 5.0【ASP.NET MVC 5.0中的过滤器】

    ASP.NET Filers用来在MVC框架的不同请求处理阶段,注入额外的逻辑.过滤器为横切关注点提供了一种方法(日志记录,授权,缓存). 在这篇文章中,我将会向你介绍MVC框架支持的各种不同种类过滤 ...

  9. yesno孤立词识别kaldi脚本

    path.sh主要设定路径等 export KALDI_ROOT=`pwd`/../../.. [ -f $KALDI_ROOT/tools/env.sh ] && . $KALDI_ ...

  10. 机器学习框架之sklearn简介

    简介 今天为大家介绍的是scikit-learn.sklearn是一个Python第三方提供的非常强力的机器学习库,它包含了从数据预处理到训练模型的各个方面.在实战使用scikit-learn中可以极 ...