月度归档:2011年07月

用Word 2007以上版本发布WordPress文章

微软的Office2003升级至Office2007时,Office套件功能就越来越强大和人性化。最新的办公软件Word绝对的是个好东东,顺应潮流添加了很多很实用的新功能。今天就来说说如何用Word来发布文章到WordPress。

上网百度或谷歌一下,关键词:Word 发布文章 WordPress。会翻阅到一堆关于用Word发布文章到Wordpress,也看了一些,都没有说的不是很详细,所以有跟贴的一些朋友,评论其文章说,完全按照步骤,测试后竟没有成功。下面就来说说详细的过程,作为一个总结吧。

第一步:WordPress的设置(必须

1、进入WordPress的控制板的设置,点击撰写;

2、在远程发布这一项中的”启用 WordPress、Movable Type、MetaWeblog 和 Blogger 的 XML-RPC 发布协议”前面打勾;

3、然后点击保存更改。

 

第二步:服务器的配置(非必须

1、注意这一步是非必须步骤,如果你的WordPress架设在Apache这类环境下请直接跳过,看第三步,如果不是请继续看第二步;

2、如果你的WordPress运行在IIS环境中,并且启用了伪静态的固定链接,请在您的静态规则文件httpd.ini文件中,加入规则代码,禁止WordPress根目录下的xmlrpc.php文件伪静态;3、(关于WordPress的伪静态规则文件详细编写,可参考尘圈:《WordPress伪静态的解决方法之httpd.ini》

第三步:Word的操作

1、下载,安装Office,当然已安装完毕的请跳过;

2、运行Word,写入并编辑好文章;

3、点击Word最左上角的Office按钮,选择发布选项,并从弹出菜单中选择博客选项;

4、在弹出窗口中选择立即注册选项;

5、在弹出窗口中的博客提供商里面选择WordPress;

6、在新建WordPress窗口中填写博客的地址,用户名和密码;

7、在弹出的警告窗口中选择是,为了以后省心点,顺便把不再显示此消息那个勾给打上;

8、帐户注册成功;

9、把文章标题填上,并且你可以选择直接发布,或者发布为草稿;

10、可以在管理帐户中更改现有帐户,或者新建帐户都行——如果你有多个博客的话。

用Word发布文章到WordPress的优缺点

优点——

1、多一个工具,多一个选择;

2、相对于了 ScribeFire, Zoundry和skyblog,word我们要熟悉的多;

3、不是每个人都使用Firefox;

4、不是每个人都喜欢装那么多软件;

5、也是最重要的一点,使用word,即使是在上班的时候blogging,也绝不会被Boss发现,嘿嘿:)比较安全!

缺点——

1、发布的文章只能到WordPress的文章的默认分类;

2、发布的文章不能够添加自定义文章标签

所以,用Word发布文章到WordPress还是有一定局限性,要不要用,就看你自己的需要啦。

 

Message Confidentiality Practice(RSA and base 64)

Click here to download code (NB: You should register first)

[download id=”3″]

 

Part 1

Message Confidentiality
Practice

This demo made a simple implementation of Message Confidentiality. It encrypt/decrypt with a message using public/private key pair.

Author: Huan Meng huanm@kth.se

 

The process of operation:

1. Generate two random numbers:

 

2. Generate key pairs:

 

3. Click “Ecryption” and get the Ciphertext(record the ciphertext). Input the record ciphertext or delete the plaintext and click “Decryption”:

 

The main source code is as follows:

unit Unit1;

 

interface

 

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, Spin, ComCtrls;

 

type

TForm1 = class(TForm)

Button1: TButton;

Button2: TButton;

Edit1: TEdit;

Edit2: TEdit;

Edit3: TEdit;

Edit4: TEdit;

Edit5: TEdit;

Edit6: TEdit;

Edit7: TEdit;

Edit8: TEdit;

Edit9: TEdit;

Edit10: TEdit;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label7: TLabel;

Label8: TLabel;

Label9: TLabel;

Label10: TLabel;

Button3: TButton;

Button4: TButton;

Button5: TButton;

edit13: TMemo;

edit11: TRichEdit;

Label11: TLabel;

Label12: TLabel;

Edit12: TEdit;

Label14: TLabel;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button4Click(Sender: TObject);

procedure Button5Click(Sender: TObject);

procedure Button6Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

 

var

Form1: TForm1;

 

implementation

 

uses ranlib, FGInt, FGIntPrimeGeneration, FGIntRSA;

 

{$R *.DFM}

 

procedure TForm1.Button1Click(Sender: TObject);

 

var seed, i: integer;

var s,s2: string;

 

begin

seed := Round(Time()*3600000.0);

 

WRandomInit(seed);

 

for i := 1 to 20 do begin

WRandom();

WIRandom(0,1000);

end;

s:=floattostr(WIRandom(0,1000000000));

s2:=floattostr(WIRandom(0,1000000000));

 

edit1.text:=s;

edit2.text:=s2;

end;

 

procedure TForm1.Button2Click(Sender: TObject);

var

n, e, d, dp, dq, p, q, phi, one, two, gcd, temp, nilgint,te1,te2,te3 : TFGInt;

test, signature : String;

p1,q1,dp1,dq1,e1,d1,n1,nil1,gcdStr:string;

ok : boolean;

begin

Base10StringToFGInt(edit1.text, p);

PrimeSearch(p);

Base256StringToFGInt(edit2.text, q);

PrimeSearch(q);

// Compute the modulus

FGIntMul(p, q, n);

 

// Compute p-1, q-1 by adjusting the last digit of the GInt

p.Number[1] := p.Number[1] – 1; 1

q.Number[1] := q.Number[1] – 1;

// Compute phi(n)

FGIntMul(p, q, phi);//作(p-1)*(q-1)=phi

// Choose a public exponent e such that GCD(e,phi)=1

Base10StringToFGInt(‘65537’, e);

Base10StringToFGInt(‘1’, one);

Base10StringToFGInt(‘2’, two);

FGIntGCD(phi, e, gcd);

While FGIntCompareAbs(gcd, one) <> Eq Do

Begin

FGIntadd(e, two, temp);

FGIntCopy(temp, e);

FGIntGCD(phi, e, gcd);

End;

FGIntToBase10String(e,gcdstr);

edit12.text:=gcdstr;

FGIntDestroy(two);

FGIntDestroy(one);

FGIntDestroy(gcd);

 

FGIntModInv(e, phi, d);

FGIntModInv(e, p, dp);

FGIntModInv(e, q, dq);

p.Number[1] := p.Number[1] + 1;

q.Number[1] := q.Number[1] + 1;

Base10StringToFGInt(‘100′, te1);

Base10StringToFGInt(’25’, te2);

FGIntMul(te1,te2,te3);

FGIntToBase10String(p,p1);

edit3.text:=p1;

FGIntToBase10String(q,q1);

edit4.text:=q1;

FGIntToBase10String(dp,dp1);

edit5.text:=dp1;

FGIntToBase10String(dq,dq1);

edit6.text:=dq1;

FGIntToBase10String(e,e1);

edit7.text:=e1;

FGIntToBase10String(d,d1);

edit8.text:=d1;

FGIntToBase10String(n,n1);

edit9.text:=n1;

FGIntToBase10String(phi,nil1);

edit10.text:=nil1;

FGIntDestroy(phi);

 

FGIntDestroy(nilgint);

 

 

FGIntDestroy(p);

FGIntDestroy(q);

FGIntDestroy(dp);

FGIntDestroy(dq);

FGIntDestroy(e);

FGIntDestroy(d);

FGIntDestroy(n);

end;

 

 

procedure TForm1.Button3Click(Sender: TObject);

var

test,s,b64:string;

e,n:tfgint;

stin,ms:integer;

begin

test:=edit11.text;

Base10StringToFGInt(edit7.Text, e);

Base10StringToFGInt(edit9.text, n);

RSAEncrypt(test, e, n, test);

edit13.Clear;

ConvertBase256to64(test,b64);

//stin:=length(test) div 10;

//ms:=length(test) mod 10;

//s:=

edit13.lines.Add(b64);

 

FGIntDestroy(e);

FGIntDestroy(n);

 

end;

 

procedure TForm1.Button4Click(Sender: TObject);

var

test,b64:string;

d,n,nilgint:tfgint;

begin

test:=edit13.text;

ConvertBase64to256(test,b64);

test:=”;

Base10StringToFGInt(edit8.Text, d);

Base10StringToFGInt(edit9.text, n);

RSADecrypt(b64, d, n, Nilgint, Nilgint, Nilgint, Nilgint, test);

edit11.text:=test;

FGIntDestroy(d);

FGIntDestroy(n);

FGIntDestroy(nilgint);

end;

 

procedure TForm1.Button5Click(Sender: TObject);

begin

edit11.clear;

edit13.clear;

end;

 

procedure TForm1.Button6Click(Sender: TObject);

var

a,b,c:tfgint;

ss:string;

begin

Base10StringToFGInt(edit1.Text,a);

Base10StringToFGInt(edit2.Text,b);

FGIntModInv(a,b,c);

FGIntToBase10String(c,ss);

 

FGIntDestroy(a);

FGIntDestroy(b);

FGIntDestroy(c);

 

end;

 

end.

 

 

end.

 

Conclusion

By encrypting the arbitrary message using secret key cryptography with a public/private key pair, it assures the confidentiality of the message.

Compile environment: Delphi 7

 

 

Part 2

Message Confidentiality Practice

This demo made a simple implementation of Message Confidentiality. It encrypt/decrypt an arbitrary message using secret key cryptography, including Base64 encoding.

Author: Jing Ba jingb@kth.se

 

The process of operation:

1. Input the arbitrary message:


 

2. Click “Base64 Ecryption” and get the Ciphertext(record the ciphertext):


3. Input the record ciphertext or delete the plaintext and click “Base64 Decryption”:


 

4. We get the plaintext:


 

The main source code is as follows:

unit Unit1;

 

interface

 

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls;

 

type

TForm1 = class(TForm)

Button1: TButton;

Button2: TButton;

Edit1: TEdit;

Edit2: TEdit;

Label1: TLabel;

Label2: TLabel;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

 

var

Form1: TForm1;

function Base64Encode(const s: string): string;

function Base64Decode(const s: string): string;

implementation

 

{$R *.dfm}

 

function Base64Encode(const s: string): string;

var

i,c1,c2,c3: Integer;

m,n: Integer;

const

Base64: string = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/’;

begin

Result := ”;

m:=1;

n:=0;

for i := 1 to (Length(s) div 3) do

begin

c1 := Ord(s[m]);

c2 := Ord(s[m+1]);

c3 := Ord(s[m+2]);

m:=m+3;

Result := Result+base64[(c1 shr 2)and $3F+1];

Result := Result+base64[((c1 shl 4)and $30) or ((c2 shr 4)and $0F)+1];

Result := Result+base64[((c2 shl 2)and $3C) or ((c3 shr 6)and $03)+1];

Result := Result+base64[c3 and $3F+1];

n:=n+4;

if(n = 76)then

begin

n:=0;

Result := Result+#13#10;

end;

end;

if (Length(s) mod 3)=1 then

begin

c1 := Ord(s[m]);

Result := Result+base64[(c1 shr 2)and $3F+1];

Result := Result+base64[(c1 shl 4)and $30+1];

Result := Result+’=’;

Result := Result+’=’;

end;

if (Length(s) mod 3)=2 then

begin

c1 := Ord(s[m]);

c2 := Ord(s[m+1]);

Result := Result+ base64[(c1 shr 2)and $3F+1];

Result := Result+ base64[((c1 shl 4)and $30) or ((c2 shr 4)and $0F)+1];

Result := Result+base64[(c2 shl 2)and $3C+1];

Result := Result+ ‘=’;

end;

end;

 

function Base64Decode(const s: string): string;

var

i,m,n: Integer;

c1,c2,c3,c4: Integer;

const

Base64: string = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/’;

begin

Result := ”;

n:=1;

m:=Length(s);

if s[m]=’=’then m:=m-1;

if s[m]=’=’then m:=m-1;

for i:=1 to m div 4 do

begin

c1:=Pos(s[n],Base64)-1;

c2:=Pos(s[n+1],Base64)-1;

c3:=Pos(s[n+2],Base64)-1;

c4:=Pos(s[n+3],Base64)-1;

n:=n+4;

Result:=Result+Chr(((c1 shl 2)and $FC)or((c2 shr 4)and $3));

Result:=Result+Chr(((c2 shl 4)and $F0)or((c3 shr 2)and $0F));

Result:=Result+Chr(((c3 shl 6)and $C0)or c4);

end;

if m mod 4=2 then

begin

c1:=Pos(s[n],Base64)-1;

c2:=Pos(s[n+1],Base64)-1;

Result:=Result+Chr(((c1 shl 2)and $FC)or((c2 shr 4)and $3));

end;

 

if m mod 4=3 then

begin

c1:=Pos(s[n],Base64)-1;

c2:=Pos(s[n+1],Base64)-1;

c3:=Pos(s[n+2],Base64)-1;

Result:=Result+Chr(((c1 shl 2)and $FC)or((c2 shr 4)and $3));

Result:=Result+Chr(((c2 shl 4)and $F0)or((c3 shr 2)and $0F));

end;

 

end;

 

procedure TForm1.Button1Click(Sender: TObject);

begin

Edit2.Text :=Base64Encode(Edit1.Text);

end;

 

procedure TForm1.Button2Click(Sender: TObject);

begin

Edit1.Text :=Base64Decode(Edit2.Text);

end;

 

procedure TForm1.FormCreate(Sender: TObject);

begin

 

end;

 

end.

 

 

Conclusion

By encrypting the arbitrary message using secret key cryptography with Base64 encoding, it assures the confidentiality of the message.

Compile environment: Delphi 7

Security for Java and E-commerce Environments

Click here to download code (NB: You should register first)

[download id=”6″]

 

Assignment 5 (Client/Server Message Security)

Purpose: Develop an AC module to login users and accept their (typed) message. The module should comprehensively protect the message using a combination of secret and public key cryptography. Channel protection should be provided by the SSL (through JSSE), message protection by the PKCS#7 or S/MIME formats.

 

Client/Server

1. Operate server:


2. Register for users:


 

3. Login:


 

4. Chat (message transfer)


Main code:

1. AppServer.java

//Code for the connect class

class Connect

{

ObjectOutputStream streamToClient;

int ctr=0;


BufferedReader streamFromClient;


static
Vector
vector;

static
Vector
vctrList;

String message=” “;

static String str=new String(“UsrList”);

 

static

{


vector=new
Vector(1,1);

vctrList=new
Vector(1,1);

vctrList.addElement((String)str);

}

 

 

int verify(String mesg)

{


try

{

RandomAccessFile RAS=new RandomAccessFile(“UsrPwd.txt”, “r”);

int
i=0;

String str=””;

while((RAS.getFilePointer())!=(RAS.length()))

{

str=RAS.readLine();

if(str.equals(mesg))

{

ctr=1;

break;


}

}

RAS.close();

}

catch(Exception e)

{


}


return ctr;


 

}//end of verify()

 

2. clientInt.java

class TimerAction implements ActionListener

{

Socket toServer;

ObjectInputStream streamFromServer;

PrintStream streamToServer;

public
void actionPerformed(ActionEvent e2)

{

 

try

{

toServer=new Socket(“machine-name”,1001);

streamFromServer=new ObjectInputStream(toServer.getInputStream());

streamToServer=new PrintStream(toServer.getOutputStream());

message=txtMsg.getText();


//send a message to the server

streamToServer.println(“From Timer”);


//receive vectors from the server

Vector vector=(Vector)streamFromServer.readObject();

Vector vector1=(Vector)streamFromServer.readObject();


//show the online users

txtListUsers.setText(“”);

for(int j=1;j<vector1.capacity();j++)

{

txtListUsers.append((String)vector1.elementAt(j));

txtListUsers.append(“\n”);

}


//show the messsages

int i=messageCount;

for(;i<vector.capacity();i++)

{

 

txtMessages.append((String)vector.elementAt(i));

txtMessages.append(“\n”);


}

messageCount=i;

}//end of try

 

catch(Exception e)

{

System.out.println(“Exception “+e);

}

 

}//end of actionPerformed

}//end of TimerListener class

 

3.
Register.java

public
void actionPerformed(ActionEvent e1)

{

 

JButton button=(JButton)e1.getSource(); //get the source of the event

if(button.equals(btnCancel))

{

this.dispose();

}

else

{

int ver=verify(); //call the verify()

if(ver==1)

{


try

{

//establish a socket connection and create I/O socket streams

toServer=new Socket(“machine-name”,1001);

streamFromServer=new ObjectInputStream(toServer.getInputStream());

streamToServer=new PrintStream(toServer.getOutputStream());

 

//send a message to server for Registration

streamToServer.println(“RegisterInfo”);

usrName=txtUserName.getText();

usrPwd=txtUsrPwd.getPassword();

String pwd=new String(usrPwd);

 

//send the user name and password to the server

streamToServer.println(usrName+”:”+pwd);

 

//read the response from the server

String frmServer=(String)streamFromServer.readObject();

if(frmServer.equals(“Registered”))

{

new Login();

this.dispose();

}

else
if(frmServer.equals(“User Exists”))

{


showUsrExists(); //show error message

}

 

}//end of try

catch(Exception e)

{

System.out.println(“Exception “+e);

}

}//end of if

 

}//end of else

}//end of actionPerformed()

 

4. Login.java

public
void actionPerformed(ActionEvent e1)

{

JButton button=(JButton)e1.getSource();

if(button.equals(btnCancel))

{

this.dispose(); //close the current frame

}

else
if(button.equals(btnRegister))

{

new Register(); //call Register program

this.dispose();

}

else

{

 

try

{

//create socket and input-output socket streams

toServer=new Socket(“machine-name”,1001);

streamFromServer=new ObjectInputStream(toServer.getInputStream());

streamToServer=new PrintStream(toServer.getOutputStream());

 

//send message to server for login

streamToServer.println(“LoginInfo”);

UsrName=txtUsrName.getText();

UsrPwd=txtUsrPwd.getPassword();

strPwd=new String(UsrPwd);

 

//send the user name and password to the server

streamToServer.println(UsrName+”:”+strPwd);


//read the message from the server

String frmServer=(String)streamFromServer.readObject();


if(frmServer.equals(“Welcome”))

{

new clientInt(UsrName); //start the chat screen

this.dispose();

}

else

{

showdlg();//show error message

}

 

}//end of try

catch(Exception e)

{

System.out.println(“Exception Occured: “+e);

}

}//end of if..else

}//end of actionPerformed

 

SSL through JSSE

Simple client/sever includes SimpleSSLServer and SimpleSSLClient. We should configure KeyStore and TrustStore files before we operate the program.

We use keytool to generate KeyStore, clientStore and serverstore which contain the authorization for A, B and Server.

Establish authorization for Bob:


Check the authorization:


Generate certificate:


Export the certificate:


File list:


Operate server:


Operate client:


 

PKCS#7 implementation

Use java Security package. There is no PKCS#7 for digital signature in jdk. So we use BASE64 code as follows: