首先uname -r看一下你当前的linux内核版本
1、linux的源码是在/usr/src这个目录下,此目录有你电脑上各个版本的linux内核源代码,用uname -r命令可以查看你当前使用的是哪套内核,你把你下载的内核源码也保存到这个目录之下。
2、配置内核 make menuconfig,根据你的需要来进行选择,设置完保存之后会在当前目录下生成.config配置文件,以后的编译会根据这个来有选择的编译。
3、编译,依次执行make、make bzImage、make moles、make moles
4、安装,make install
5、.创建系统启动映像,到 /boot 目录下,执行 mkinitramfs -o initrd.img-2.6.36 2.6.36
6、修改启动项,因为你在启动的时候会出现多个内核供你选择,此事要选择你刚编译的那个版本,如果你的电脑没有等待时间,就会进入默认的,默认的那个取决于 /boot/grub/grub.cfg 文件的设置,找到if [ "${linux_gfx_mode}" != "text" ]这行,他的第一个就是你默认启动的那个内核,如果你刚编译的内核是在下面,就把代表这个内核的几行代码移到第一位如:
menuentry 'Ubuntu, with Linux 3.2.0-35-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root 9961c170-2566-41ac-8155-18f231c1bea5
linux/boot/vmlinuz-3.2.0-35-generic root=UUID=9961c170-2566-41ac-8155-18f231c1bea5 ro quiet splash $vt_handoff
initrd/boot/initrd.img-3.2.0-35-generic
}
当然你也可以修改 set default="0"来决定用哪个,看看你的内核在第几位,default就填几,不过我用过这种方法,貌似不好用。
重启过后你编译的内核源码就成功地运行了,如果出现问题,比如鼠标不能用,usb不识别等问题就好好查查你的make menuconfig这一步,改好后就万事ok了。
最后再用uname -r看看你的linux内核版本。是不是你刚下的那个呢!有没有成就感?
打字不易,如满意,望采纳。
实际你的代码可以优化成这样
<?php
function RandAbc($length=""){//返回随机字符串
$str="";
return str_shuffle($str);
}
$filename='234.php';
$T_k1=RandAbc();//随机密匙1
$T_k2=RandAbc();//随机密匙2
$vstr=file_get_contents($filename);//要加密的文件
$v1=base64_encode($vstr);
$c=strtr($v1,$T_k1,$T_k2);//根据密匙替换对应字符。
$c=$T_k1.$T_k2.$c;
$q1="O00O0O";
$q2="O0O000";
$q3="O0OO00";
$q4="OO0O00";
$q5="OO0000";
$q6="O00OO0";
$O00OO0="n1zb/ma5\vt0i28-pxuqy*6lrkdg9_ehcswo4+f37j";
$O00O0O=$O00OO0{3}.$O00OO0{6}.$O00OO0{33}.$O00OO0{30};$O0OO00=$O00OO0{33}.$O00OO0{10}.$O00OO0{24}.$O00OO0{10}.$O00OO0{24};
$OO0O00=$O0OO00{0}.$O00OO0{18}.$O00OO0{3}.$O0OO00{0}.$O0OO00{1}.$O00OO0{24};
$OO0000=$O00OO0{7}.$O00OO0{13};$O00O0O.=$O00OO0{22}.$O00OO0{36}.$O00OO0{29}.$O00OO0{26}.$O00OO0{30}.$O00OO0{32}.$O00OO0{35}.$O00OO0{26}.$O00OO0{30};
eval($O00O0O("JE8wTzAwMD0iIjtldmFsKCc/KSkpOw=="));
$s='<?
'.$s.
'
?>';
echo $s;
//生成 加密后的PHP文件
!is_dir('create/') && mkdir('create/');
$fpp1 = fopen('create/'.$filename,'w');
fwrite($fpp1,$s) or die('写文件错误');
echo '加密成功!';
?>
然后继续优化
<?php
function RandAbc($length=""){//返回随机字符串
$str="";
return str_shuffle($str);
}
$filename='234.php';
$T_k1=RandAbc();//随机密匙1
$T_k2=RandAbc();//随机密匙2
$vstr=file_get_contents($filename);//要加密的文件
$v1=base64_encode($vstr);
$c=strtr($v1,$T_k1,$T_k2);//根据密匙替换对应字符。
$c=$T_k1.$T_k2.$c;
$q1="O00O0O";
$q2="O0O000";
$q3="O0OO00";
$q4="OO0O00";
$q5="OO0000";
$q6="O00OO0";
$O00OO0="n1zb/ma5\vt0i28-pxuqy*6lrkdg9_ehcswo4+f37j";
$O00O0O='bawh';
$O0OO00='w0k0k';
$OO0O00='wqbw0k';
$OO0000='58';
$O00O0O.='bawhl+eghs4gh'
eval($O00O0O("JE8wTzAwMD0iIjtldmFsKCc/KSkpOw=="));
$s='<?
'.$s.
'
?>';
echo $s;
//生成 加密后的PHP文件
!is_dir('create/') && mkdir('create/');
$fpp1 = fopen('create/'.$filename,'w');
fwrite($fpp1,$s) or die('写文件错误');
echo '加密成功!';
?>
看到这里我们不难发现这代码有错误,
$O00O0O='bawh';
$O0OO00='w0k0k';
$OO0O00='wqbw0k';
$OO0000='58';
$O00O0O.='bawhl+eghs4gh'
这几个变量值定义的不正确 所以肯定无法正确加密了。
按照道理应该是 base 64 substr这些字符串。
所以你这代码是有问题的。
⑶ 35dir分类目录bug怎么修改
善记事博客好像有挺多这方面的文章介绍,望采纳
⑷ 谁有比较好的Delphi书籍(比较详细的那种)
多看来收集到的有关Delphi的书集,现大大部分应该还可以找到吧!
----------------------------------------------------
2008-11-16 16:36 <DIR> Borland InterBase7.0 应用开发指南
2008-06-01 10:02 <DIR> COM+开发人员参考库
2008-11-16 16:35 <DIR> COM技术内幕
2008-11-29 00:59 7,205,961 Delphi 7信息系统设计与开发实例(PDF).rar
2008-06-01 10:50 <DIR> Delphi COM 深入编程
2008-11-16 16:47 <DIR> Delphi ERP开发
2008-11-16 16:47 <DIR> Delphi Win32核心API参考
2008-06-01 12:45 <DIR> Delphi Win32核心API参考光盘内容
2008-11-16 16:39 <DIR> Delphi 中的DLL封装和调用对象技术
2008-11-16 16:46 <DIR> Delphi 串口及语音传真高级编程
2008-06-01 12:44 <DIR> Delphi 外设应用
2008-10-26 17:41 <DIR> Delphi 多媒体技术开发与实例
2008-06-01 12:44 <DIR> Delphi 学习大全
2008-06-01 12:44 <DIR> Delphi 实效编程百例
2008-06-01 12:43 <DIR> Delphi 常用技巧及经典教材
2008-11-16 16:39 <DIR> Delphi 应用技巧与常见问题你问我答
2008-11-16 16:39 <DIR> Delphi 应用程序开发精彩实例
2008-06-01 12:42 <DIR> Delphi 技术全集
2008-11-16 16:38 <DIR> Delphi 数字图像处理及高级应用
2008-11-16 16:38 <DIR> Delphi 深入Windows 核心编程
2008-11-16 16:38 <DIR> Delphi 深度历险
2008-06-01 12:41 <DIR> Delphi 深度编程及其项目应用开发
2008-06-01 12:41 <DIR> Delphi 第三方控件使用大全(Ⅱ)
2008-06-01 12:41 <DIR> Delphi 算法与数据结构
2008-06-01 12:41 <DIR> Delphi 经典编程入门
2008-06-01 12:41 <DIR> Delphi 网络应用
2008-06-01 12:41 <DIR> Delphi 网络应用开发技术与实例
2008-10-26 17:29 <DIR> Delphi 网络通信协议分析与应用实现
2008-11-16 16:47 <DIR> Delphi 部件开发指南
2008-06-01 12:39 <DIR> Delphi 面向对象编程思想
2008-11-16 16:46 <DIR> Delphi 高手的成长之路
2008-11-16 16:46 <DIR> Delphi 高手突破
2008-11-16 16:35 <DIR> Delphi5 ADO.MTS.COM+高级程序设计篇
2008-11-16 16:35 <DIR> Delphi5 COM.CORBA.Internet.Program
2008-11-16 16:36 <DIR> Delphi5 企业级解决方案及应用剖析
2008-11-16 16:36 <DIR> Delphi5 开发人员指南
2008-11-26 11:14 <DIR> Delphi5 数据库开发技术
2008-11-16 16:36 <DIR> Delphi5 程序员指南
2008-11-26 12:11 <DIR> Delphi5 编程实例与技巧
2008-11-19 22:34 <DIR> Delphi6 Kylix2 Soap Web Service程序设计
2008-11-19 22:34 <DIR> Delphi6 企业级解决方案及应用剖析
2008-11-19 22:34 <DIR> Delphi6 函数大全
2008-11-19 22:34 <DIR> Delphi6 分布式开发
2008-11-19 22:34 <DIR> Delphi6 实例入门
2008-11-19 22:35 <DIR> Delphi6 实务经典
2008-11-19 22:35 <DIR> Delphi6 帮助文件中英文对照
2009-06-12 00:47 <DIR> Delphi6 应用开发指南
2008-11-19 22:35 <DIR> Delphi6 开发人员指南
2008-11-19 22:35 <DIR> Delphi6 开发者手册
2008-11-19 22:35 <DIR> Delphi6 数据库系统开发实例导航
2008-11-19 22:35 <DIR> Delphi6 最佳专辑
2008-11-19 22:35 <DIR> delphi6 深入编程技术
2008-11-19 22:35 <DIR> Delphi6 深入网络编程
2008-11-19 22:35 <DIR> Delphi6 灵感编程范例代码
2008-11-19 22:35 <DIR> Delphi6 电子商务应用开发
2008-11-19 22:35 <DIR> Delphi6 程序设计从入门至精通
2008-11-19 22:35 <DIR> Delphi6 程序设计教程
2008-11-19 22:35 <DIR> Delphi6 组件大全
2008-11-19 22:35 <DIR> Delphi6 编程基础
2008-11-19 22:35 <DIR> Delphi6 高级开发范例
2008-11-19 22:35 <DIR> Delphi6 高级编程
2008-06-01 12:31 <DIR> Delphi7 80例上手Delphi编程
2008-06-01 12:30 <DIR> Delphi7 anli
2008-06-01 12:30 <DIR> Delphi7 从入门到精通
2008-06-01 12:29 <DIR> Delphi7 创建Intraweb应用程序
2008-06-01 12:29 <DIR> Delphi7 完美经典
2008-06-01 12:29 <DIR> Delphi7 实用编程100例
2008-06-01 12:28 <DIR> Delphi7 应用编程150例
2008-06-01 12:28 <DIR> Delphi7 控件实用程序实际100例
2008-06-01 12:28 <DIR> Delphi7 数学单元函数中文说明
2008-06-01 12:28 <DIR> Delphi7 新概念百例
2008-11-29 00:52 6,524,051 Delphi7 程序设计与开发技术大全(PDF).rar
2008-06-01 12:28 <DIR> Delphi7 程序设计实例导学
2008-11-16 16:37 <DIR> Delphi7 程序设计技巧与实例
2008-06-01 12:27 <DIR> Delphi7 组件经典解析
2008-06-01 12:27 <DIR> Delphi7 编程实例五十讲
2008-06-01 12:27 <DIR> Delphi7 编程实战导航
2008-06-01 12:26 <DIR> Delphi7 网络应用开发
2008-06-01 12:26 <DIR> Delphi7 高级应用开发(源码)
2008-11-29 01:13 14,439,629 delphi7数据库应用开发(PDF).rar
2008-11-29 01:45 38,470,754 delphi7组件与分布式应用开发.rar
2008-06-01 12:26 <DIR> delphiwangl
2008-11-29 01:40 24,026,361 delphi算法与数据结构.rar
2008-06-01 12:25 <DIR> Indy-9-0-Help-HtmlHelp
2008-06-01 12:25 <DIR> MICROSOFT WIN32程序员参考大全
2008-06-01 12:24 <DIR> MySQLBook
2008-11-16 16:38 <DIR> Object pascal中文参考手册(可打印版)
2008-06-01 12:24 <DIR> vbWin32API
2008-06-01 12:24 <DIR> Win32开发人员参考库
2008-06-01 12:23 <DIR> windows 消息内幕
2008-11-16 16:40 <DIR> windows 系统编程第三版
2008-11-16 16:37 <DIR> windows 网络编程技术
2008-11-16 16:40 <DIR> windows 高级编程-面向对象的思想、方法和实例
2008-11-16 16:40 <DIR> windows 高级编程指南
2008-11-29 01:29 118,749,881 基于Delphi的Web程序设计(PDF).rar
2008-06-01 12:23 <DIR> 实用delphi编程
2008-06-01 12:22 <DIR> 控件应用
2008-11-16 16:37 <DIR> 李维.ECO教程
2008-11-16 16:40 <DIR> 用Delphi实现无线程序
2008-11-16 16:45 <DIR> 用Delphi编写CGI程序
2008-06-01 12:22 <DIR> 用Delphi编写Windows NT中服务程序.files
2008-11-29 01:29 35,722,082 百例课堂 delphi7 编程入门篇.rar
2008-11-16 16:37 <DIR> 编译原理及实践
2008-06-01 12:22 <DIR> 计算机图形学及附书源码
2008-06-01 12:22 <DIR> 软件加密技术内幕
2008-11-16 16:38 <DIR> 面向对象方法:原理与实践
⑸ 求java制作小程序方法
Java Applet程序开发步骤
Java Applet程序开发主要步骤如下:
1)选用EDIT或WindowsNotepad等工具作为编辑器建立Java Applet源程序。
2)把Java Applet的源程序转换为字节码文件。
3)编制使用class的HTML文件。在HTML文件内放入必要的<Java Applet>语句。
下面举一个最简单的HelloWorld例子来说明Java Applet程序的开发过程:
(1)编辑Java Applet的java源文件
创建文件夹C:ghq,在该文件夹下建立HelloWorld.java
文件的源代码如下:
importjava.awt.*;
importjava.JavaApplet.*;
//继承Appelet类,这是AppeletJava程序的特点
{
publicvoidpaint(Graphicsg)
{
g.drawString("HelloWorld!",5,35);
}
}
保存上述程序在C:ghqHelloWorld.java文件里。
(2)编译Java Applet
编译HelloWorld.java源文件可使用如下JDK命令:
C:ghq>javacHelloWorld.java<Enter>
注意:如果编写的源程序违反了Java编程语言的语法规则,Java编译器将在屏幕上显示语法错误提示信息。源文件中必须不含任何语法错误,Java编译器才能成功地把源程序转换为Java Appletviewer和浏览器能够执行的字节码程序。
成功地编译Java Applet之后生成响应的字节码文件HelloWorld.class的文件。用资源管理器或DIR命令列出目录列表,将会发现目录C:ghq中多了一个名为HelloWorld.class的文件。
(3)创建HTML文件
在运行创建的HelloWorld.class之前,还需创建一个HTML文件,Java Appletviewer或浏览器将通过该文件访问创建的Java Applet。为运行HelloWorld.class,需要创建包含如下HTML语句的名为HelloWorld.html的文件。
<HTML>
<TITLE>HelloWorld!JavaApplet</TITLE>
<JavaApplet
CODE="JavaWorld.class"
WIDTH=200
HEIGHT=100>
</JavaApplet>
</HTML>
本例中,<Java Applet>语句指明该Java Applet字节码类文件名和以像素为单位的窗口的尺寸。虽然这里HTML文件使用的文件名为HelloWorld.HTML,它对应于HelloWorld.java的名字,但这种对应关系不是必须的,可以用其他的任何名字(比如说Ghq.HTML)命名该HTML文件。但是使文件名保持一种对应关系可给文件的管理带来方便。
(4)执行HelloWorld.html
如果用Java Appletviewer运行HelloWorld.html,需输入如下的命令行:
C:ghq>JavaAppletviewerJavaWorld.html<ENTER>
可以看出,该命令启动了Java Appletviewer并指明了HTML文件,该HTML文件中包含对应于HelloWorld的<Java Applet>语句。
如果用浏览器运行HelloWorldJava Applet,需在浏览器的地址栏中输入HTML文件URL地址。
至此,一个Java Applet程序的开发运行整个过程结束了(包括java源文件、编译的class文件、html文件以及用Java Appletviewer或用浏览器运行)。
⑹ des算法源代码
des.h文件:
#ifndef CRYPTOPP_DES_H
#define CRYPTOPP_DES_H
#include "cryptlib.h"
#include "misc.h"
NAMESPACE_BEGIN(CryptoPP)
class DES : public BlockTransformation
{
public:
DES(const byte *userKey, CipherDir);
void ProcessBlock(const byte *inBlock, byte * outBlock) const;
void ProcessBlock(byte * inoutBlock) const
{DES::ProcessBlock(inoutBlock, inoutBlock);}
enum {KEYLENGTH=8, BLOCKSIZE=8};
unsigned int BlockSize() const {return BLOCKSIZE;}
protected:
static const word32 Spbox[8][64];
SecBlock<word32> k;
};
class DESEncryption : public DES
{
public:
DESEncryption(const byte * userKey)
: DES (userKey, ENCRYPTION) {}
};
class DESDecryption : public DES
{
public:
DESDecryption(const byte * userKey)
: DES (userKey, DECRYPTION) {}
};
class DES_EDE_Encryption : public BlockTransformation
{
public:
DES_EDE_Encryption(const byte * userKey)
: e(userKey, ENCRYPTION), d(userKey + DES::KEYLENGTH, DECRYPTION) {}
void ProcessBlock(const byte *inBlock, byte * outBlock) const;
void ProcessBlock(byte * inoutBlock) const;
enum {KEYLENGTH=16, BLOCKSIZE=8};
unsigned int BlockSize() const {return BLOCKSIZE;}
private:
DES e, d;
};
class DES_EDE_Decryption : public BlockTransformation
{
public:
DES_EDE_Decryption(const byte * userKey)
: d(userKey, DECRYPTION), e(userKey + DES::KEYLENGTH, ENCRYPTION) {}
void ProcessBlock(const byte *inBlock, byte * outBlock) const;
void ProcessBlock(byte * inoutBlock) const;
enum {KEYLENGTH=16, BLOCKSIZE=8};
unsigned int BlockSize() const {return BLOCKSIZE;}
private:
DES d, e;
};
class TripleDES_Encryption : public BlockTransformation
{
public:
TripleDES_Encryption(const byte * userKey)
: e1(userKey, ENCRYPTION), d(userKey + DES::KEYLENGTH, DECRYPTION),
e2(userKey + 2*DES::KEYLENGTH, ENCRYPTION) {}
void ProcessBlock(const byte *inBlock, byte * outBlock) const;
void ProcessBlock(byte * inoutBlock) const;
enum {KEYLENGTH=24, BLOCKSIZE=8};
unsigned int BlockSize() const {return BLOCKSIZE;}
private:
DES e1, d, e2;
};
class TripleDES_Decryption : public BlockTransformation
{
public:
TripleDES_Decryption(const byte * userKey)
: d1(userKey + 2*DES::KEYLENGTH, DECRYPTION), e(userKey + DES::KEYLENGTH, ENCRYPTION),
d2(userKey, DECRYPTION) {}
void ProcessBlock(const byte *inBlock, byte * outBlock) const;
void ProcessBlock(byte * inoutBlock) const;
enum {KEYLENGTH=24, BLOCKSIZE=8};
unsigned int BlockSize() const {return BLOCKSIZE;}
private:
DES d1, e, d2;
};
NAMESPACE_END
#endif
des.cpp文件:
// des.cpp - modified by Wei Dai from:
/*
* This is a major rewrite of my old public domain DES code written
* circa 1987, which in turn borrowed heavily from Jim Gillogly's 1977
* public domain code. I pretty much kept my key scheling code, but
* the actual encrypt/decrypt routines are taken from from Richard
* Outerbridge's DES code as printed in Schneier's "Applied Cryptography."
*
* This code is in the public domain. I would appreciate bug reports and
* enhancements.
*
* Phil Karn KA9Q, [email protected], August 1994.
*/
#include "pch.h"
#include "misc.h"
#include "des.h"
NAMESPACE_BEGIN(CryptoPP)
/* Tables defined in the Data Encryption Standard documents
* Three of these tables, the initial permutation, the final
* permutation and the expansion operator, are regular enough that
* for speed, we hard-code them. They're here for reference only.
* Also, the S and P boxes are used by a separate program, gensp.c,
* to build the combined SP box, Spbox[]. They're also here just
* for reference.
*/
#ifdef notdef
/* initial permutation IP */
static byte ip[] = {
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6,
64, 56, 48, 40, 32, 24, 16, 8,
57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
61, 53, 45, 37, 29, 21, 13, 5,
63, 55, 47, 39, 31, 23, 15, 7
};
/* final permutation IP^-1 */
static byte fp[] = {
40, 8, 48, 16, 56, 24, 64, 32,
39, 7, 47, 15, 55, 23, 63, 31,
38, 6, 46, 14, 54, 22, 62, 30,
37, 5, 45, 13, 53, 21, 61, 29,
36, 4, 44, 12, 52, 20, 60, 28,
35, 3, 43, 11, 51, 19, 59, 27,
34, 2, 42, 10, 50, 18, 58, 26,
33, 1, 41, 9, 49, 17, 57, 25
};
/* expansion operation matrix */
static byte ei[] = {
32, 1, 2, 3, 4, 5,
4, 5, 6, 7, 8, 9,
8, 9, 10, 11, 12, 13,
12, 13, 14, 15, 16, 17,
16, 17, 18, 19, 20, 21,
20, 21, 22, 23, 24, 25,
24, 25, 26, 27, 28, 29,
28, 29, 30, 31, 32, 1
};
/* The (in)famous S-boxes */
static byte sbox[8][64] = {
/* S1 */
14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13,
/* S2 */
15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9,
/* S3 */
10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12,
/* S4 */
7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14,
/* S5 */
2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3,
/* S6 */
12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13,
/* S7 */
4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12,
/* S8 */
13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11
};
/* 32-bit permutation function P used on the output of the S-boxes */
static byte p32i[] = {
16, 7, 20, 21,
29, 12, 28, 17,
1, 15, 23, 26,
5, 18, 31, 10,
2, 8, 24, 14,
32, 27, 3, 9,
19, 13, 30, 6,
22, 11, 4, 25
};
#endif
/* permuted choice table (key) */
static const byte pc1[] = {
57, 49, 41, 33, 25, 17, 9,
1, 58, 50, 42, 34, 26, 18,
10, 2, 59, 51, 43, 35, 27,
19, 11, 3, 60, 52, 44, 36,
63, 55, 47, 39, 31, 23, 15,
7, 62, 54, 46, 38, 30, 22,
14, 6, 61, 53, 45, 37, 29,
21, 13, 5, 28, 20, 12, 4
};
/* number left rotations of pc1 */
static const byte totrot[] = {
1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28
};
/* permuted choice key (table) */
static const byte pc2[] = {
14, 17, 11, 24, 1, 5,
3, 28, 15, 6, 21, 10,
23, 19, 12, 4, 26, 8,
16, 7, 27, 20, 13, 2,
41, 52, 31, 37, 47, 55,
30, 40, 51, 45, 33, 48,
44, 49, 39, 56, 34, 53,
46, 42, 50, 36, 29, 32
};
/* End of DES-defined tables */
/* bit 0 is left-most in byte */
static const int bytebit[] = {
0200,0100,040,020,010,04,02,01
};
/* Set key (initialize key schele array) */
DES::DES(const byte *key, CipherDir dir)
: k(32)
{
SecByteBlock buffer(56+56+8);
byte *const pc1m=buffer; /* place to modify pc1 into */
byte *const pcr=pc1m+56; /* place to rotate pc1 into */
byte *const ks=pcr+56;
register int i,j,l;
int m;
for (j=0; j<56; j++) { /* convert pc1 to bits of key */
l=pc1[j]-1; /* integer bit location */
m = l & 07; /* find bit */
pc1m[j]=(key[l>>3] & /* find which key byte l is in */
bytebit[m]) /* and which bit of that byte */
? 1 : 0; /* and store 1-bit result */
}
for (i=0; i<16; i++) { /* key chunk for each iteration */
memset(ks,0,8); /* Clear key schele */
for (j=0; j<56; j++) /* rotate pc1 the right amount */
pcr[j] = pc1m[(l=j+totrot[i])<(j<28? 28 : 56) ? l: l-28];
/* rotate left and right halves independently */
for (j=0; j<48; j++){ /* select bits indivially */
/* check bit that goes to ks[j] */
if (pcr[pc2[j]-1]){
/* mask it in if it's there */
l= j % 6;
ks[j/6] |= bytebit[l] >> 2;
}
}
/* Now convert to odd/even interleaved form for use in F */
k[2*i] = ((word32)ks[0] << 24)
| ((word32)ks[2] << 16)
| ((word32)ks[4] << 8)
| ((word32)ks[6]);
k[2*i+1] = ((word32)ks[1] << 24)
| ((word32)ks[3] << 16)
| ((word32)ks[5] << 8)
| ((word32)ks[7]);
}
if (dir==DECRYPTION) // reverse key schele order
for (i=0; i<16; i+=2)
{
std::swap(k[i], k[32-2-i]);
std::swap(k[i+1], k[32-1-i]);
}
}
/* End of C code common to both versions */
/* C code only in portable version */
// Richard Outerbridge's initial permutation algorithm
/*
inline void IPERM(word32 &left, word32 &right)
{
word32 work;
work = ((left >> 4) ^ right) & 0x0f0f0f0f;
right ^= work;
left ^= work << 4;
work = ((left >> 16) ^ right) & 0xffff;
right ^= work;
left ^= work << 16;
work = ((right >> 2) ^ left) & 0x33333333;
left ^= work;
right ^= (work << 2);
work = ((right >> 8) ^ left) & 0xff00ff;
left ^= work;
right ^= (work << 8);
right = rotl(right, 1);
work = (left ^ right) & 0xaaaaaaaa;
left ^= work;
right ^= work;
left = rotl(left, 1);
}
inline void FPERM(word32 &left, word32 &right)
{
word32 work;
right = rotr(right, 1);
work = (left ^ right) & 0xaaaaaaaa;
left ^= work;
right ^= work;
left = rotr(left, 1);
work = ((left >> 8) ^ right) & 0xff00ff;
right ^= work;
left ^= work << 8;
work = ((left >> 2) ^ right) & 0x33333333;
right ^= work;
left ^= work << 2;
work = ((right >> 16) ^ left) & 0xffff;
left ^= work;
right ^= work << 16;
work = ((right >> 4) ^ left) & 0x0f0f0f0f;
left ^= work;
right ^= work << 4;
}
*/
// Wei Dai's modification to Richard Outerbridge's initial permutation
// algorithm, this one is faster if you have access to rotate instructions
// (like in MSVC)
inline void IPERM(word32 &left, word32 &right)
{
word32 work;
right = rotl(right, 4U);
work = (left ^ right) & 0xf0f0f0f0;
left ^= work;
right = rotr(right^work, 20U);
work = (left ^ right) & 0xffff0000;
left ^= work;
right = rotr(right^work, 18U);
work = (left ^ right) & 0x33333333;
left ^= work;
right = rotr(right^work, 6U);
work = (left ^ right) & 0x00ff00ff;
left ^= work;
right = rotl(right^work, 9U);
work = (left ^ right) & 0xaaaaaaaa;
left = rotl(left^work, 1U);
right ^= work;
}
inline void FPERM(word32 &left, word32 &right)
{
word32 work;
right = rotr(right, 1U);
work = (left ^ right) & 0xaaaaaaaa;
right ^= work;
left = rotr(left^work, 9U);
work = (left ^ right) & 0x00ff00ff;
right ^= work;
left = rotl(left^work, 6U);
work = (left ^ right) & 0x33333333;
right ^= work;
left = rotl(left^work, 18U);
work = (left ^ right) & 0xffff0000;
right ^= work;
left = rotl(left^work, 20U);
work = (left ^ right) & 0xf0f0f0f0;
right ^= work;
left = rotr(left^work, 4U);
}
// Encrypt or decrypt a block of data in ECB mode
void DES::ProcessBlock(const byte *inBlock, byte * outBlock) const
{
word32 l,r,work;
#ifdef IS_LITTLE_ENDIAN
l = byteReverse(*(word32 *)inBlock);
r = byteReverse(*(word32 *)(inBlock+4));
#else
l = *(word32 *)inBlock;
r = *(word32 *)(inBlock+4);
#endif
IPERM(l,r);
const word32 *kptr=k;
for (unsigned i=0; i<8; i++)
{
work = rotr(r, 4U) ^ kptr[4*i+0];
l ^= Spbox[6][(work) & 0x3f]
^ Spbox[4][(work >> 8) & 0x3f]
^ Spbox[2][(work >> 16) & 0x3f]
^ Spbox[0][(work >> 24) & 0x3f];
work = r ^ kptr[4*i+1];
l ^= Spbox[7][(work) & 0x3f]
^ Spbox[5][(work >> 8) & 0x3f]
^ Spbox[3][(work >> 16) & 0x3f]
^ Spbox[1][(work >> 24) & 0x3f];
work = rotr(l, 4U) ^ kptr[4*i+2];
r ^= Spbox[6][(work) & 0x3f]
^ Spbox[4][(work >> 8) & 0x3f]
^ Spbox[2][(work >> 16) & 0x3f]
^ Spbox[0][(work >> 24) & 0x3f];
work = l ^ kptr[4*i+3];
r ^= Spbox[7][(work) & 0x3f]
^ Spbox[5][(work >> 8) & 0x3f]
^ Spbox[3][(work >> 16) & 0x3f]
^ Spbox[1][(work >> 24) & 0x3f];
}
FPERM(l,r);
#ifdef IS_LITTLE_ENDIAN
*(word32 *)outBlock = byteReverse(r);
*(word32 *)(outBlock+4) = byteReverse(l);
#else
*(word32 *)outBlock = r;
*(word32 *)(outBlock+4) = l;
#endif
}
void DES_EDE_Encryption::ProcessBlock(byte *inoutBlock) const
{
e.ProcessBlock(inoutBlock);
d.ProcessBlock(inoutBlock);
e.ProcessBlock(inoutBlock);
}
void DES_EDE_Encryption::ProcessBlock(const byte *inBlock, byte *outBlock) const
{
e.ProcessBlock(inBlock, outBlock);
d.ProcessBlock(outBlock);
e.ProcessBlock(outBlock);
}
void DES_EDE_Decryption::ProcessBlock(byte *inoutBlock) const
{
d.ProcessBlock(inoutBlock);
e.ProcessBlock(inoutBlock);
d.ProcessBlock(inoutBlock);
}
void DES_EDE_Decryption::ProcessBlock(const byte *inBlock, byte *outBlock) const
{
d.ProcessBlock(inBlock, outBlock);
e.ProcessBlock(outBlock);
d.ProcessBlock(outBlock);
}
void TripleDES_Encryption::ProcessBlock(byte *inoutBlock) const
{
e1.ProcessBlock(inoutBlock);
d.ProcessBlock(inoutBlock);
e2.ProcessBlock(inoutBlock);
}
void TripleDES_Encryption::ProcessBlock(const byte *inBlock, byte *outBlock) const
{
e1.ProcessBlock(inBlock, outBlock);
d.ProcessBlock(outBlock);
e2.ProcessBlock(outBlock);
}
void TripleDES_Decryption::ProcessBlock(byte *inoutBlock) const
{
d1.ProcessBlock(inoutBlock);
e.ProcessBlock(inoutBlock);
d2.ProcessBlock(inoutBlock);
}
void TripleDES_Decryption::ProcessBlock(const byte *inBlock, byte *outBlock) const
{
d1.ProcessBlock(inBlock, outBlock);
e.ProcessBlock(outBlock);
d2.ProcessBlock(outBlock);
}
NAMESPACE_END
⑺ mysql5.6.33源码编译
重点不是这里,重点是下面的错误:
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Unknown/unsupported table type: InnoDB
[ERROR] Aborting
把你的 datadir 数据目录清空。重新运行mysql_install_db
⑻ 如何系统的学习Linux驱动开发
在学习之前一直对驱动开发非常的陌生,感觉有点神秘。不知道驱动开发和普通的程序开发究竟有什么不同;它的基本框架又是什么样的;他的开发环境有什么特殊的地方;以及怎么写编写一个简单的字符设备驱动前编译加载,下面我就对这些问题一个一个的介绍。
一、驱动的基本框架
1.那么究竟什么是驱动程序,它有什么用呢:
l驱动是硬件设备与应用程序之间的一个中间软件层
l它使得某个特定硬件能够响应一个定义良好的内部编程接口,同时完全隐蔽了设备的工作细节
l用户通过一组与具体设备无关的标准化的调用来完成相应的操作
l驱动程序的任务就是把这些标准化的系统调用映射到具体设备对于实际硬件的特定操作上
l驱动程序是内核的一部分,可以使用中断、DMA等操作
l驱动程序在用户态和内核态之间传递数据
2.Linux驱动的基本框架
3.Linux下设备驱动程序的一般可以分为以下三类
1)字符设备
a)所有能够象字节流一样访问的设备都通过字符设备来实现
b)它们被映射为文件系统中的节点,通常在/dev/目录下面
c)一般要包含open read write close等系统调用的实现
2)块设备
d)通常是指诸如磁盘、内存、Flash等可以容纳文件系统的存储设备。
e)块设备也是通过文件系统来访问,与字符设备的区别是:内核管理数据的方式不同
f)它允许象字符设备一样以字节流的方式来访问,也可一次传递任意多的字节。
3)网络接口设备
g)通常它指的是硬件设备,但有时也可能是一个软件设备(如回环接口loopback),它们由内核中网络子系统驱动,负责发送和接收数据包。
h)它们的数据传送往往不是面向流的,因此很难将它们映射到一个文件系统的节点上。
二、怎么搭建一个驱动的开发环境
因为驱动是要编译进内核,在启动内核时就会驱动此硬件设备;或者编译生成一个.o文件,当应用程序需要时再动态加载进内核空间运行。因此编译任何一个驱动程序都要链接到内核的源码树。所以搭建环境的第一步当然是建内核源码树
1.怎么建内核源码树
a)首先看你的系统有没有源码树,在你的/lib/ moles目录下会有内核信息,比如我当前的系统里有两个版本:
#ls /lib/ moles
2.6.15-rc72.6.21-1.3194.fc7
查看其源码位置:
## ll /lib/moles/2.6.15-rc7/build
lrwxrwxrwx 1 root root 27 2008-04-28 19:19 /lib/moles/2.6.15-rc7/build -> /root/xkli/linux-2.6.15-rc7
发现build是一个链接文件,其所对应的目录就是源码树的目录。但现在这里目标目录已经是无效的了。所以得自己重新下载
b)下载并编译源码树
有很多网站上可以下载,但官方网址是:
http://www.kernel.org/pub/linux/kernel/v2.6/
下载完后当然就是解压编译了
# tar –xzvf linux-2.6.16.54.tar.gz
#cd linux-2.6.16.54
## make menuconfig (配置内核各选项,如果没有配置就无法下一步编译,这里可以不要改任何东西)
#make
…
如果编译没有出错。那么恭喜你。你的开发环境已经搭建好了
三、了解驱动的基本知识
1.设备号
1)什么是设备号呢?我们进系统根据现有的设备来讲解就清楚了:
#ls -l /dev/
crwxrwxrwx 1 root root1,3 2009-05-11 16:36 null
crw------- 1 root root4,0 2009-05-11 16:35 systty
crw-rw-rw- 1 root tty5,0 2009-05-11 16:36 tty
crw-rw---- 1 root tty4,0 2009-05-11 16:35 tty0
在日期前面的两个数(如第一列就是1,3)就是表示的设备号,第一个是主设备号,第二个是从设备号
2)设备号有什么用呢?
l传统上,主编号标识设备相连的驱动.例如, /dev/null和/dev/zero都由驱动1来管理,而虚拟控制台和串口终端都由驱动4管理
l次编号被内核用来决定引用哪个设备.依据你的驱动是如何编写的自己区别
3)设备号结构类型以及申请方式
l在内核中, dev_t类型(在中定义)用来持有设备编号,对于2.6.0内核, dev_t是32位的量, 12位用作主编号, 20位用作次编号.
l能获得一个dev_t的主或者次编号方式:
MAJOR(dev_t dev); //主要
MINOR(dev_t dev);//次要
l但是如果你有主次编号,需要将其转换为一个dev_t,使用: MKDEV(int major, int minor);
4)怎么在程序中分配和释放设备号
在建立一个字符驱动时需要做的第一件事是获取一个或多个设备编号来使用.可以达到此功能的函数有两个:
l一个是你自己事先知道设备号的
register_chrdev_region,在中声明:
int register_chrdev_region(dev_t first, unsigned int count, char *name);
first是你要分配的起始设备编号. first的次编号部分常常是0,count是你请求的连续设备编号的总数. name是应当连接到这个编号范围的设备的名子;它会出现在/proc/devices和sysfs中.
l第二个是动态动态分配设备编号
int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, unsigned int count, char *name);
使用这个函数, dev是一个只输出的参数,它在函数成功完成时持有你的分配范围的第一个数. fisetminor应当是请求的第一个要用的次编号;它常常是0. count和name参数如同给request_chrdev_region的一样.
5)设备编号的释放使用
不管你是采用哪些方式分配的设备号。使用之后肯定是要释放的,其方式如下:
void unregister_chrdev_region(dev_t first, unsigned int count);
6)
2.驱动程序的二个最重要数据结构
1)file_operation
倒如字符设备scull的一般定义如下:
struct file_operations scull_fops = {
.owner = THIS_MODULE,
.llseek = scull_llseek,
.read = scull_read,
.write = scull_write,
.ioctl = scull_ioctl,
.open = scull_open,
.release = scull_release,
};
file_operation也称为设备驱动程序接口
定义在,是一个函数指针的集合.每个打开文件(内部用一个file结构来代表)与它自身的函数集合相关连(通过包含一个称为f_op的成员,它指向一个file_operations结构).这些操作大部分负责实现系统调用,因此,命名为open, read,等等
2)File
定义位于include/fs.h
struct file结构与驱动相关的成员
lmode_t f_mode标识文件的读写权限
lloff_t f_pos当前读写位置
lunsigned int_f_flag文件标志,主要进行阻塞/非阻塞型操作时检查
lstruct file_operation * f_op文件操作的结构指针
lvoid * private_data驱动程序一般将它指向已经分配的数据
lstruct dentry* f_dentry文件对应的目录项结构
3.字符设备注册
1)内核在内部使用类型struct cdev的结构来代表字符设备.在内核调用你的设备操作前,必须编写分配并注册一个或几个这些结构.有2种方法来分配和初始化一个这些结构.
l如果你想在运行时获得一个独立的cdev结构,可以这样使用:
struct cdev *my_cdev = cdev_alloc();
my_cdev->ops = &my_fops;
l如果想将cdev结构嵌入一个你自己的设备特定的结构;你应当初始化你已经分配的结构,使用:
void cdev_init(struct cdev *cdev, struct file_operations *fops);
2)一旦cdev结构建立,最后的步骤是把它告诉内核,调用:
int cdev_add(struct cdev *dev, dev_t num, unsigned int count);
说明:dev是cdev结构, num是这个设备响应的第一个设备号, count是应当关联到设备的设备号的数目.常常count是1,但是有多个设备号对应于一个特定的设备的情形.
3)为从系统去除一个字符设备,调用:
void cdev_del(struct cdev *dev);
4.open和release
⑼ 怎样用C语言编一个简单的五子棋游戏
#include <graphics.h>
#include <stdio.h>
#include <MATH.H>
IMAGE* IMG;
IMAGE* IMG2;
IMAGE* IMG3;
IMAGE* whole;
bool mark = false;
int x = 0, y = 0;
int flag[15][15];
void show()
{
outtextxy(550, 100, "白方:");
outtextxy(550, 150, " 箭头移动");
outtextxy(550, 200, " 回车键落子");
outtextxy(550, 250, "黑方:");
outtextxy(550, 300, " ADWS移动");
outtextxy(550, 350, " 空格键落子");
}
int success1(int dir1, int dir2)
{
int number = 0;
int temp_x = x, temp_y = y;
while (((temp_x / 35 + dir1) >= 0 && (temp_x / 35 + dir1) < 15) && ((temp_y / 35 + dir2) >= 0 && (temp_y / 35 + dir2) < 15) && (flag[(temp_x / 35 + dir1)][(temp_y / 35 + dir2)] == 1))
{
temp_x = temp_x + dir1 * 35;
temp_y = temp_y + dir2 * 35;
++number;
}
return number;
}
int success2(int dir1, int dir2)
{
int number = 0;
int temp_x = x, temp_y = y;
while (((temp_x / 35 + dir1) >= 0 && (temp_x / 35 + dir1) < 15) && ((temp_y / 35 + dir2) >= 0 && (temp_y / 35 + dir2) < 15) && (flag[(temp_x / 35 + dir1)][(temp_y / 35 + dir2)] == 2))
{
temp_x = temp_x + dir1 * 35;
temp_y = temp_y + dir2 * 35;
++number;
}
return number;
}
int success1()
{
int number = 0;
number = success1(0, -1) + success1(0, 1);//上下
if (number < 4)
{
number = success1(-1, 0) + success1(1, 0);//左右
if (number < 4)
{
number = success1(-1, -1) + success1(1, 1);//左上右下
if (number < 4)
{
number = success1(-1, 1) + success1(1, -1);//左下右上
}
}
}
return number;
}
int success2()
{
int number = 0;
number = success2(0, -1) + success2(0, 1);//上下
if (number < 4)
{
number = success2(-1, 0) + success2(1, 0);//左右
if (number < 4)
{
number = success2(-1, -1) + success2(1, 1);//左上右下
if (number < 4)
{
number = success2(-1, 1) + success2(1, -1);//左下右上
}
}
}
return number;
}
void control()
{
char key = 0;
while (key != 27)
{
Sleep(10);
if (kbhit())
{
key = getch();
switch (key)
{
case VK_LEFT:
if (mark)
break;
if (x > 0)
x = x - 35;
break;
case 'a':
case 'A':
if (!mark)
break;
if (x > 0)
x = x - 35;
break;
case VK_RIGHT:
if (mark)
break;
if (x < 490)
x = x + 35;
break;
case 'd':
case 'D':
if (!mark)
break;
if (x < 490)
x = x + 35;
break;
case VK_UP:
if (mark)
break;
if (y > 0)
y = y - 35;
break;
case 'w':
case 'W':
if (!mark)
break;
if (y > 0)
y = y - 35;
break;
case VK_DOWN:
if (mark)
break;
if (y < 490)
y = y + 35;
break;
case 's':
case 'S':
if (!mark)
break;
if (y < 490)
y = y + 35;
break;
case VK_RETURN:
if (mark)
break;
if (flag[x / 35][y / 35] == 0)
{
putimage(whole, x + 6, y + 6, 31, 32, IMG2, 0, 0);
flag[x / 35][y / 35] = 1;
if (success1() >= 4)
{
outtextxy(600, 50, "黑方 胜!");
key = 27;
}
mark = true;
}
break;
case VK_SPACE:
if (!mark)
break;
if (flag[x / 35][y / 35] == 0)
{
putimage(whole, x + 6, y + 6, 31, 31, IMG3, 0, 0);
flag[x / 35][y / 35] = 2;
if (success2() >= 4)
{
outtextxy(600, 50, "白方 胜!");
key = 27;
}
mark = false;
}
break;
default:
break;
}
putimage(0, 0, whole);
putimage_transparent(NULL, IMG, x + 20, y + 20, 0x0, 0, 0, 20, 20);
}
}
}
void main()
{
setinitmode(0);
initgraph(800, 538);
SetWindowText(GetHWnd(), "五子棋20110327");
setcolor(0xffffff);
setfont(36, 0, "楷体_GB2312");
IMAGE* IMG1 = new IMAGE;
getimage(IMG1, "JPG", MAKEINTRESOURCE(102));//棋盘
putimage(0, 0, IMG1);
IMG2 = new IMAGE;
getimage(IMG2, "JPG", MAKEINTRESOURCE(103));//黑棋
IMG3 = new IMAGE;
getimage(IMG3, "JPG", MAKEINTRESOURCE(104));//白棋
IMG = new IMAGE;
getimage(IMG, "GIF", MAKEINTRESOURCE(101));//手形
whole = new IMAGE;
getimage(whole, 0, 0, 537, 537);
putimage_transparent(NULL, IMG, x + 20, y + 20, 0x0, 0, 0, 20, 20);
show();
control();
delete IMG1;
delete IMG2;
delete IMG3;
delete whole;
getch();
getch();
closegraph();
}