博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
阅读杂记(RSA,PDO)
阅读量:7167 次
发布时间:2019-06-29

本文共 2254 字,大约阅读时间需要 7 分钟。

RSA算法

RSA Key Size Selection

这篇文章说的是如何选择RSA密钥的长度。RSA密钥的长度是可以选择的,RSA密钥的长度影响加密后的长度,可以加密的串长度,加密和解密的时间。

 

简单来说就是:

1 密钥长度和可加密的字符串长度成正比。RSA的密钥越长,其对应公钥可以加密的字符串的字节数也会对应加长。其加密后的字符串的长度也越长。

2 密钥长度和算法复杂度成正比。密钥越长,破解需要的时间也就越长,算法复杂度也就越高。

3 密钥长度和加密解密的时间成正比。密钥越长,加密解密时间也就越长。

所以如何选择一个安全又高效的RSA密钥长度是很重要的。在2000年,研究表示1024bit长度的密钥的破解需要花费使用一套10亿美金的设备破解10年的时间。基本上1024bit的长度就能保证RSA的安全了。(PHP的RSA默认就是生成和使用1024bit的密钥)

1024bit长度的密钥能加密117byte的字节,最后生成的加密串有256byte长。

PDO相关阅读

PDO封装了数据库的操作。

 

事务

PDO有事务的概念,相关的方法是:

PDO::beginTransaction

PDO::commit

PDO::rollBack

分别是开始事务,提交事务,回滚事务

PDO::inTransaction 判断是否在一个事务中

 

PDO有预处理方法:

PDO::prepare

实际上就是SQL的模板,这个方法返回的是PDOStatement数据结构。

prepare的参数表示可以使用:name 或者 ? 来表示,但是两种不能混用。

PDO::prepare调用后对应的执行方法是PDO::execute

 

PDOStatement

PDOStatement有个queryString的属性,查出query的语句

还有的其他方法有:

  •  — Bind a column to a PHP variable

将返回的某一列指定给php的某个变量。通常和fetch还有fetchAll联合使用

  •  — Binds a parameter to the specified variable name
  •  — Binds a value to a parameter

bindParam和bindValue都是将query模板的对应参数做替换,但是bindParam值将模板中的对应参数替换成为变量并执行之后,如果有输出变量的话会将这个变量进行改变。bindValue就不会。

  •  — Closes the cursor, enabling the statement to be executed again.

关闭指针。PDO会有个指针来定位结果集。所以当有两个statement的时候,在两个statement中切换的时候要先使用closeCursor来切换

  •  — Dump an SQL prepared command

调试使用

  •  — Fetch the SQLSTATE associated with the last operation on the statement handle
  •  — Fetch extended error information associated with the last operation on the statement handle

这两个函数用来输出错误信息

  •  — Executes a prepared statement

执行prepare中的语句,返回的结果使用fetch来获取

  •  — Fetches the next row from a result set

获取一行数据

  •  — Returns an array containing all of the result set rows

获取多行数据

  •  — Returns a single column from the next row of a result set

获取某列值,获取单个

  •  — Fetches the next row and returns it as an object.
  • 同fetch,只是fetch的style是PDO::FETCH_OBJ
  •  — Retrieve a statement attribute
  •  — Returns metadata for a column in a result set
  •  — Advances to the next rowset in a multi-rowset statement handle

指针下移一位,和fetch一起使用可以获取全部rowset

  •  — Returns the number of rows affected by the last SQL statement
  •  — Returns the number of columns in the result set

获取结果的行数和列数

  •  — Set a statement attribute

设置statement的属性

  •  — Set the default fetch mode for this statement

设置statement的Mode,可以设置把最后的对象变为什么样子

本文转自轩脉刃博客园博客,原文链接:http://www.cnblogs.com/yjf512/archive/2012/10/19/2731302.html,如需转载请自行联系原作者

你可能感兴趣的文章
读python官方教程的一些记录
查看>>
CentOS 6 安装
查看>>
运算符、表达式概论
查看>>
软件架构师应该知道的97件事
查看>>
Linux 用户和组 (4) userdel
查看>>
php面向对象三,继承父类extends
查看>>
网络编程学习——带外数据
查看>>
iOS开发编码建议与编程经验
查看>>
linux文件权限
查看>>
关于Spring事务回滚的问题
查看>>
JRE冲掉了JDK
查看>>
Spring MVC 教程,快速入门,深入分析——关于写几个配置文件的说明
查看>>
我的友情链接
查看>>
MongDB副本集replset测试【MongDB系列二】
查看>>
Android开发之旅:环境搭建及HelloWorld
查看>>
php/web缓存Cache为王
查看>>
化妆品零售变革 电子商务VS传统零售
查看>>
我的友情链接
查看>>
Truncate/Delete/Drop table的特点和区别
查看>>
我的友情链接
查看>>