delphi pchar 的问题

delphi pchar 的问题,第1张

推测 Pbu,Pmy,mykey 应该各自对应一个字串

pbu[i]、mykey[] 对应字串里的字元

ord( pbu[i]) 则是把字元换成 ascii 码

mod 取馀数

enc := (ord(pbu[i])+ord(mykey[(i mod length(key))])) mod 256;

貌似利用 key 对 pbu 加密後再填到 Pmy。

《午夜邂逅 (2014)》高清资源下载观看:

1234

《午夜邂逅》是由克里斯·埃文斯执导,克里斯·埃文斯、爱丽丝·伊芙主演的剧情**。该片于2014年9月12日在多伦多**节上映。

该片讲述了两个在曼哈顿相遇的陌生人,一夜之内通过彼此间的冲突与碰撞,变得更加了解对方和自己的故事。    

推荐《小萝莉的猴神大叔》、《调音师》、《超龄少女》、《最初的梦想》、《摔跤吧!爸爸》这五部**,这五部**的豆瓣评分都在8分以上,颇受广大影迷欢迎。

1、《小萝莉的猴神大叔》

**讲述了一个拥有虔诚宗教信仰的单纯印度男人帮助巴基斯坦哑女与父母重聚的故事。印度教教徒帕万(萨尔曼·汗 饰)在一次机缘巧合下结识了与母亲走失并有语言障碍的穆斯林小女孩沙希达(哈尔莎莉·马尔霍特 饰)。

在得知沙希达是巴基斯坦人后,帕万决定帮助她回家,可在回巴基斯坦途中却四处碰壁,遭遇领事馆冲突、被旅游局欺骗之后,帕万立志将不惜一切代价尽其所能带沙希达回到自己的家乡与家人团聚。

2、《调音师》

阿德里安(格雷戈瓦·勒普兰斯-林盖饰)是一个学习钢琴已有15年之久的天才钢琴家,可是在梦寐以求的伯恩斯坦钢琴大赛上他功败垂成,人生跌落谷底。经过一段时间调整,阿德里安重新振作,成为了一名盲人钢琴调音师。

事实上他只是带上了隐形眼镜,这会让别人认为他听觉方面更加敏锐,并由此得到更多的同情和消费,甚至还会窥视到别人的生活与隐私,他兀自沉浸在这种虽处闹市又仿佛置身世外的超然之中。某天,他来到一户人家工作,殊不知这里刚刚发生一起凶案。

3、《超龄少女》

正值妙龄的Swati(萨曼莎·鲁斯·帕布饰)拥有令人闻之即醉的歌声,一次在外演唱 时被音乐制作人Vikram发现,后参加当地的歌唱比赛一举成名,但是年轻貌美的 Swati总是会做出一些不符年龄的举动:岔开腿坐着、教训年轻人、说自己早已结婚 生子、抠脚、指导人做菜……种种怪异的举动背后,实则隐藏着一个巨大的秘密。

4、《最初的梦想》

被帕塔克(苏尚特·辛格·拉吉普特 饰)寄予厚望的儿子拉加夫高考失利,因无法忍受“失败者”的标签而发生意外。面对病床前丧失信心的儿子,帕塔克讲述了大学时代,自己与朋友们以及前妻玛雅(施拉达·卡普尔 饰),为了完成“失败者”的逆袭,在冠军联赛中“损招”尽出的故事。一段啼笑皆非的青春往事揭开帷幕,他们会实现最初的梦想吗?

5、《摔跤吧!爸爸》

马哈维亚·辛格·珀尕(阿米尔·汗饰)曾是印度国家摔跤冠军,因生活所迫放弃摔跤。他希望让儿子可以帮他完成梦想——赢得世界级金牌。

结果生了四个女儿本以为梦想就此破碎的辛格却意外发现女儿身上的惊人天赋,看到冠军希望的他决定不能让女儿的天赋浪费,像其他女孩一样只能洗衣做饭过一生 ,再三考虑之后,与妻子约定一年时间按照摔跤手的标准训练两个女儿:换掉裙子 、剪掉了长发,让她们练习摔跤,并赢得一个又一个冠军,最终赢来了成为榜样激励千千万万女性的机会。

在Delphi中预定义了Tfilestream类,通过它可以对磁盘文件进行读写,笔者选定Tfilestream为基类,通过对其核心的两个读、写方法进行重载,编写定制的文件流,实现对文件的读、写进行加密。

首先,来看一下定制文件流(Tmystream)的声明:

type

Tmystream=class(Tfilestream)

private

fkey:string;

public

constructor create

(const filename:string;mode:word);

function read(var buffer;count:longint):

longint;override;

function write(const buffer;count:longint):

longint;override;

property key:string read fkey write fkey ;

end;

在Tmystream的声名中,我们对read、write两个方法进行了重载,并添加了一个新的特性key,用以存储对文件进行加密时所需的密码。为实现文件读写的加密,在write方法中,将key的每个字符依次与buffer中的字符相加,将得到的结果写入文件,实现加密;在read方法中,将读出的内容依次与key的每个字符相减,实现解密。加密及解密的方法多种多样,读者可以通过改写相关代码,得到不同的加密方法。

程序清单如下:

function Tmystreamwrite(const buffer;

count:longint):longint;

var

Pbu,Pmy,mykey:pchar;

i,enc:integer;

begin

getmem(pmy,count); //为pmy分配内存

mykey:=pchar(key); //将key转换为pchar指针

try

pbu:=pchar(@buffer); //将buffer转换为pchar指针

for i:=0 to count-1 do

//将key的每个字符以此与buffer的

每个字符循环相加,结果放入pmy指向的内存区

begin

enc:=(ord(pbu[i])+ord(mykey

[(i mod length(key))])) mod 256;

Pmy[i]:=char(enc);

end;

result:=inherited write(Pmy^,count);

//将pmy指向的内容写入文件

finally

freemem(Pmy,count);

end;

end;

function Tmystreamread(var buffer;count:longint):

longint;

var

Pbu,Pmy,mykey:pchar;

i,mycount,enc:integer;

begin

getmem(Pmy,count);//为pmy分配内存

mykey:=pchar(key);//将key转换为pchar指针

try

mycount:=inherited read(Pmy^,count);

//将文件内容读入pmy指向内存区

Pbu:=Pchar(@buffer);将buffer转换为pchar指针

for i:=0 to mycount-1 do//将key的每个字符依次

与pmy的每个字符循环相减,结果放入pbu指向的变量

begin

enc:=(ord(Pmy[i])-ord(mykey

[(i mod length(key))])) mod 256;

Pbu[i]:=chr(enc);

end;

finally

freemem(P count);

end;

result:=mycount;

end;

完成定制文件流的编写后,便可在程序中应用,实现文件的读写加密,例程如下:

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Classes,

Graphics, Controls, Forms, Dialogs,

ExtCtrls, StdCtrls,unit2,unit3;

//unit2定义了Tmystream

//unit3定义了输入密码对话框form3

type

TForm1 = class(TForm)

Button1: TButton;

Button2: TButton;

Button3: TButton;

OpenDialog1: TOpenDialog;

SaveDialog1: TSaveDialog;

Panel1: TPanel;

Panel2: TPanel;

Memo1: TMemo;

Splitter1: TSplitter;

Memo2: TMemo;

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R DFM}

procedure TForm1Button2Click(Sender: TObject);

//将选定的加密文件解开,读入memo2

var

encstr:Tmystream;

begin

if opendialog1Execute and (form3showmodal=mrok)

then

begin

encstr:=Tmystreamcreate

(opendialog1filename,fmopenread);

encstrkey:=form3Edit1Text;

try

memo2linesLoadFromStream(encstr);

finally

encstrFree;

end;

end;

end;

procedure TForm1Button3Click(Sender: TObject);

//将memo1中的内容加密,用指定文件名另存

var

encstr:Tmystream;

begin

if savedialog1Execute and (form3showmodal=mrok)

then

begin

encstr:=Tmystreamcreate(savedialog1filename,

fmcreate);

encstrkey:=form3Edit1Text;

try

memo1linesSaveToStream(encstr);

finally

encstrFree;

end;

end;

end;

procedure TForm1Button1Click(Sender: TObject);

//将指定文件读入memo1

var

mystr:Tfilestream;

begin

if opendialog1Execute then

begin

mystr:=Tfilestreamcreate

(opendialog1filename,fmopenread);

try

memo1linesLoadFromStream(mystr);

finally

mystrFree;

end;

end;

end;

end

以上程序均在windows 98、Delphi40环境中,通过编译,运行正常。

The wisdom of one word

改变一生的邂逅

 Isn't it amazing how one person, sharing one idea, at the right time and place can change the course of your life's history This is certainly what happened in my life When I was 14, I was hitchhiking from Houston, Texas, through El Paso on my way to California I was following my dream, journeying with the sun I was a high school dropout with learning disabilities and was set on surfing the biggest waves in the world, first in California and then in Hawaii, where I would later live

如果一个人,在适当的时候和地方因为一句话而改变了他的人生历程,你会感到惊异和不可思议吗?然而这的确是千真万确的,它就发生在我14岁那年。那时,我正在从得克萨斯州的休斯敦,经由爱坡索市前往加利福尼亚州去的旅途中。日出即行,日落即息;痴痴地追寻着我的梦想。我本来在读高中,也许我天生就不是读书的材料,因此我不得不中途辍学。随即我决心要到世界上的海浪上去冲浪,先准备到加利福尼亚州,再到夏威夷,然后我准备就在那里住下来。

 Upon reaching downtown El Paso, I met an old man, a bum, on the street corner He saw me walking, stopped me and questioned me as I passed by He asked me if I was running away from home, I suppose because I looked so young I told him, "Not exactly, sir," since my father had given me a ride to the freeway in Houston and given me his blessings while saying, "It is important to follow your dream and what is in your heart Son "

在刚进入爱坡索市区的时候,我看到有一个老头,一个流浪者,坐在街道的拐角处。他看见了走路的我,当我就要从他的旁边走过去时,他拦住了我,并开口向我发问。他问我是不是偷着从家里跑出来的,我想他这么问我一定是看我太年轻,觉得我太嫩的缘故。“不完全是,先生,”因为是我爸爸开车把我送到休斯敦的高速公路上的,他还一边为我祝福,一边说:“儿子,追寻你的梦想和心中的憧憬非常重要。”

 The bum then asked me if he could buy me a cup of coffee I told him, "No, sir, but a soda would be great" We walked to a corner malt shop and sat down on a couple of swiveling stools while we enjoyed our drinks

然后那个流浪者问我他能请我喝咖啡吗?我回答说:“不,先生,一杯汽水就可以了。”于是,我们走进街道拐角处的一家酒吧,坐在一双转椅上,喝着饮料。

 After conversing for a few minutes, the friendly bum told me to follow him He told me that he had something grand to show me and share with me We walked a couple of blocks until we came upon the downtown El Paso Public Library

在闲聊了几分钟后,这个和蔼可亲的老流浪汉要我跟他走。他告诉我说他有一样大东西给我看,要与我分享。我们走过了几个街区,来到了爱坡索市的公立图书馆。

 We walked up its front steps and stopped at a small information stand Here the bum spoke to a smiling old lady, and asked her if she would be kind enough to watch my things for a moment while he and I entered the library I left my belongings with this grandmotherly figure and entered into this magnificent hall of learning

我们沿着它前面的台阶向上走,在一处小小的咨询台前停了下来。老流浪汉向一位笑容可掬的老太太说了几句话,并问她是否愿意在他和我进图书馆时帮忙照看一下我的行李。我把行李放在那位老奶奶般的人那里,走进了那座宏伟的学习殿堂。

 The bum first led me to a table and asked me to sit down and wait for a moment while he looked for something special amongst the shelves A few moments later, he returned with a couple of old books under his arms and set them on the table He then sat down beside me and spoke He started with a few statements that were very special and that changed my life He said, "There are two things that I want to teach you, young man, and they are these:

老流浪汉先把我带到一张桌子前,让我坐下来稍等片刻,而他则到那些林立的书架中去寻找那个特别重要的东西去了。不一会儿,他腋下夹着几本旧书回来了。他把书放到桌子上,然后他在我的身边坐了下来,打开了话匣子,出口便不凡,其话语非常特别,改变了我一生的命运。他说:“年轻人,我想教你两件事,就是:

 "Number one is to never judge a book by its cover, for a cover can fool you "He followed with, "I ll bet you think I m a bum, don t you, young man"

第一是切记不要从封面来判断一本书的好坏,因为封面有时也会蒙骗你。”他接着说道:“我敢打赌,你一定认为我是个老流浪汉,是不是?年轻人。”

 I said, "Well, uh, yes, I guess so, sir "

我说:“嗯,是的,先生,我想是的。”

 "Well, young man, I ve got a little surprise for you I am one of the wealthiest men in the world I have probably everything any man could ever want I originally come from the Northeast and have all the things that money can buy But a year ago, my wife passed away, bless her soul, and since then I have been deeply reflecting upon life I realized there were certain things I had not yet experienced in life,one of which was what it would be like to live like a bum on the streets I made a commitment11 to myself to do exactly that for one year For the past year1 have been going from city to city doing just that So, you see, don t ever judge a book by its cover, for a cover can fool you

“嗯,年轻人,我要给你一个小惊喜:其实我是这个世界上最富有的人之一,人们梦寐以求的任何东西我几乎都有。我最初从美国东北部来,凡是金钱能买到的东西,我全都有。但是一年前,我妻子死了,愿上帝保祐她的在天之灵,从那以后,我开始深深地反思人生的意义。我意识到,生活中有些东西我还没有体验过,其中之一就是做一个沿街乞讨的流浪汉滋味如何。于是我对自己发誓要像流浪汉一样活一年。在过去的一年里,我从一个城市流浪到另一个城市,就像流浪汉一样生活。所以,你看,切记不要从封面来判断一本书的好坏,因为封面有时也会蒙骗你。”

 "Number two is to learn how to read, my boy For there is only one thing that people can t take away from you, and that is your wisdom " At that moment, he reached forward, grabbed my right hand in his and put them upon the books he d pulled from the shelves They were the writings of Plato and Aristotle-immortal classics from ancient times

“第二,我的孩子,是要学会如何读书。因为这个世界上只有一种东西是别人无法从你的身上拿走的,那,就是你的智慧!”说到这,他俯身向着我,抓住我的右手放在他从书架中找到的书上。那是柏拉图和亚里士多德的著作--尚古以降已经流传了几千年的不朽的经典。

 The bum then led me back past the smiling old woman near the entrance, down the steps and back on the streets near where we first met His parting request was for me to never forget what he taught me

 I haven't

欢迎分享,转载请注明来源:浪漫分享网

原文地址:https://hunlipic.com/lianai/9040587.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-10-03
下一篇2023-10-03

发表评论

登录后才能评论

评论列表(0条)

    保存