| Статьи | - Примеры 3 |
Примеры 3
[color=#800000]Примеры работы с компонентами криптографии (продолжение)[/color]
В предыдущих примерах мы рассмотрели основные направления криптографической защиты данных. Но все примеры были построены на том, что ключевые пары хранились не в системе, а на внешних носителях. Нижеприведенный пример показывает, как можно создавать, удалять и просматривать доступные хранилища ключей, как можно сохранять ключевые пары в хранилищах и извлекать их оттуда
[color=#000080]Пример управления контейнерами ключей (ManagerKeyContainer)[/color]
Add(MainForm,2953706,308,259)
{
Width=485
Height=575
Caption="Manager_KeyContainers"
Position=1
link(onCreate,11251377:doWork2,[])
}
Add(FileStream,11110613,406,140)
{
link(onLoad,10746019:doConvert,[])
}
Add(Memo,9632686,427,273)
{
Left=5
Top=350
Width=285
Height=160
Font=[Courier New,8,0,0,204]
TabOrder=-1
WinStyle=2
ScrollBars=2
ReadOnly=0
}
Add(Label,11196659,49,91)
{
Left=110
Top=515
Width=85
Height=17
Font=[MS Sans Serif,8,1,0,1]
Caption="Containers"
AutoSize=1
Alignment=2
}
Add(BlockFind,15027045,504,140)
{
IncludeBlock=1
Delete=0
StartBlock="-----BEGIN KEYPAIR-----"
EndBlock="-----END KEYPAIR-----"
link(onSearch,2496483:doReplace,[])
}
Add(Replace,2496483,553,140)
{
SubStr="\r\n"
link(onReplace,6759720:doCharset,[])
}
Add(Charset,6759720,602,140)
{
Type=4
link(onCharset,12655247:doDeCrypt,[])
}
Add(StreamConvertor,10746019,455,140)
{
Mode=6
link(onResult,15027045:doSearch,[])
}
Add(EnumKeyContainers,5218690,371,273)
{
link(onEnumKeyContainers,9632686:doAdd,[])
}
Add(Button,16123604,70,154)
{
Left=300
Top=350
Width=160
Font=[MS Sans Serif,8,1,0,1]
TabOrder=-1
Caption="Add ExchContainer"
link(onClick,15158701:doEvent1,[])
}
Add(Button,14940712,70,273)
{
Left=300
Top=440
Width=160
Font=[MS Sans Serif,8,1,0,1]
TabOrder=-1
Caption="Add SignContainer"
link(onClick,13180366:doEvent1,[])
}
Add(Button,3334603,70,315)
{
Left=300
Top=465
Width=160
Font=[MS Sans Serif,8,1,0,1]
TabOrder=-1
Caption="Delete SignContainer"
link(onClick,12815180:doEvent1,[])
}
Add(Button,5078142,70,196)
{
Left=300
Top=375
Width=160
Font=[MS Sans Serif,8,1,0,1]
TabOrder=-1
Caption="Delete ExchContainer"
link(onClick,8766825:doEvent1,[])
}
Add(Button,5699729,70,231)
{
Left=300
Top=400
Width=160
Font=[MS Sans Serif,8,1,0,1]
TabOrder=-1
Caption="Export ExchKeys"
link(onClick,8607929:doEvent1,[])
}
Add(Button,14747093,70,350)
{
Left=300
Top=490
Width=160
Font=[MS Sans Serif,8,1,0,1]
TabOrder=-1
Caption="Export SignKeys"
link(onClick,3321941:doEvent1,[])
}
Add(Memo,1783972,637,378)
{
Left=5
Top=5
Width=460
Height=195
Font=[Courier New,8,0,0,204]
TabOrder=-1
WinStyle=2
ReadOnly=0
}
Add(Memo,8334407,637,476)
{
Left=5
Top=225
Width=460
Height=70
Font=[Courier New,8,0,0,204]
TabOrder=-1
WinStyle=2
ReadOnly=0
}
Add(Label,11766587,56,98)
{
Left=200
Top=205
Width=85
Height=17
Font=[MS Sans Serif,8,1,0,1]
Caption="KeyPair"
AutoSize=1
Alignment=2
}
Add(Label,15828431,63,105)
{
Left=200
Top=300
Width=85
Height=17
Font=[MS Sans Serif,8,1,0,1]
Caption="PublicKey"
AutoSize=1
Alignment=2
}
Add(Label,11158422,70,112)
{
Left=10
Top=322
Width=78
Height=17
Font=[MS Sans Serif,8,1,0,1]
Caption="PassKeyPair:"
AutoSize=1
Alignment=1
}
Add(Edit,2682454,658,70)
{
Left=105
Top=320
Width=360
Font=[MS Sans Serif,8,1,0,204]
WinStyle=2
Text="project_hiasm"
}
Add(KeyContainer,12992305,287,378)
{
link(onExportKeyPair,7596516:doSeparateMT,[])
link(ContainerName,16263063:Var2,[])
link(ImportKeyPair,12655247:Result,[(300,206)(657,206)])
}
Add(Hub,15158701,140,154)
{
OutCount=5
link(onEvent1,13878567:doWork2,[])
link(onEvent2,13512295:doWork1,[(200,167)])
link(onEvent3,2050785:doWork1,[(186,174)])
link(onEvent4,2828987:doWork2,[])
link(onEvent5,10954523:doWork2,[])
}
Add(Hub,8766825,140,196)
{
OutCount=4
link(onEvent1,9968591:doWork2,[])
link(onEvent2,15742559:doWork1,[(193,209)])
link(onEvent3,827949:doWork2,[])
link(onEvent4,4964915:doWork2,[])
}
Add(Hub,8607929,140,231)
{
link(onEvent1,9968591:doWork3,[(179,237)])
link(onEvent2,9464476:doWork1,[(179,244)])
}
Add(Memory,5634174,287,140)
{
link(onData,2261085:doStrCat,[])
}
Add(DoData,238426,224,140)
{
Data=String(crypt_project_exch)
link(onEventData,13244210:doWork2,[])
}
Add(HubEx,13878567,175,154)
{
link(onEvent,238426:doData,[(200,160)(200,146)])
}
Add(HubEx,9968591,175,196)
{
Angle=3
link(onEvent,13878567:doWork3,[])
}
Add(Hub,13180366,140,273)
{
OutCount=5
link(onEvent1,5987882:doWork2,[])
link(onEvent2,13512295:doWork2,[])
link(onEvent3,2050785:doWork2,[])
link(onEvent4,9039266:doWork2,[])
link(onEvent5,13642401:doWork2,[])
}
Add(Hub,12815180,140,315)
{
OutCount=4
link(onEvent1,959304:doWork2,[])
link(onEvent2,15742559:doWork2,[])
link(onEvent3,9039266:doWork3,[(207,335)])
link(onEvent4,13642401:doWork3,[(214,342)])
}
Add(Hub,3321941,140,350)
{
link(onEvent1,959304:doWork3,[(172,356)])
link(onEvent2,9464476:doWork2,[])
}
Add(DoData,8765797,224,273)
{
Data=String(crypt_project_sign)
link(onEventData,13244210:doWork3,[(270,279)])
}
Add(HubEx,5987882,168,273)
{
link(onEvent,8765797:doData,[])
}
Add(HubEx,959304,168,315)
{
Angle=3
link(onEvent,5987882:doWork3,[])
}
Add(HubEx,13244210,266,140)
{
link(onEvent,5634174:doValue,[])
}
Add(HubEx,13512295,196,280)
{
Angle=1
link(onEvent,12992305:doCreateKeyContainer,[(200,384)])
}
Add(HubEx,11251377,350,273)
{
link(onEvent,5218690:doEnumKeyContainers,[])
}
Add(HubEx,15742559,189,322)
{
Angle=1
link(onEvent,12992305:doDeleteKeyContainer,[(193,391)])
}
Add(StrCat,2261085,336,140)
{
Str2=".kpr"
link(onStrCat,817207:doEvent1,[])
}
Add(Hub,817207,378,140)
{
link(onEvent1,11110613:doOpen,[])
link(onEvent2,11110613:doClose,[])
}
Add(HubEx,9464476,175,357)
{
Angle=1
link(onEvent,12992305:doExportKeyPair,[(179,405)])
}
Add(HubEx,2050785,182,287)
{
Angle=1
link(onEvent,12992305:doImportKeyPair,[(186,398)])
}
Add(MultiElement,10789613,504,497)
{
@Hint=#13:Str -> Base64|
link(onEvent1,10874847:doEvent1,[])
AddHint(37,-29,79,13,@Hint)
}
BEGIN_SDK
Add(EditMulti,7118002,21,21)
{
EventCount=1
WorkCount=1
Width=328
Height=221
VOffset=21
link(doWork1,1034590:doCharset,[])
}
Add(Memory,204288,98,42)
{
link(onData,3671834:doLength,[(140,48)(140,34)(86,34)(86,125)])
}
Add(Length,3671834,98,119)
{
link(onLength,708993:doFor,[])
link(Str,13278847:Var2,[])
}
Add(For,708993,147,119)
{
Start=1
Step=64
InData=0
link(onEvent,10585589:doCopy,[])
link(onStop,8186701:doTrim,[(194,132)(194,195)])
}
Add(Copy,10585589,203,119)
{
Count=64
link(onCopy,3736710:doStrCatDlm,[])
link(Str,13278847:Var3,[(209,96)])
}
Add(GetDataEx,13278847,98,91)
{
link(Data,204288:Value,[])
}
Add(StrCatDelim,3736710,259,119)
{
Delimiter="\r\n"
Point(doClear)
link(Str1,16380385:Var3,[(265,107)(300,107)(300,166)])
}
Add(Trim,8186701,259,189)
{
Char="\r\n"
Mode=3
link(onTrim,7374949:doEvent1,[])
link(Text,16380385:Var2,[])
}
Add(Hub,7374949,308,189)
{
link(onEvent1,7118002:onEvent1,[(331,195)(331,48)])
link(onEvent2,3736710:doClear,[(331,202)(331,234)(247,234)(247,132)])
}
Add(GetDataEx,16380385,259,161)
{
link(Data,3736710:Result,[])
}
Add(Charset,1034590,42,42)
{
Type=5
link(onCharset,204288:doValue,[])
}
END_SDK
Add(MultiElement,9306811,504,399)
{
@Hint=#13:Str -> Base64|
link(onEvent1,9631313:doEvent1,[])
AddHint(37,-32,79,13,@Hint)
}
BEGIN_SDK
Add(EditMulti,15700352,21,21)
{
EventCount=1
WorkCount=1
Width=328
Height=221
VOffset=21
link(doWork1,5609255:doCharset,[])
}
Add(Memory,13733457,98,42)
{
link(onData,10859049:doLength,[(140,48)(140,34)(86,34)(86,125)])
}
Add(Length,10859049,98,119)
{
link(onLength,11434037:doFor,[])
link(Str,4897077:Var2,[])
}
Add(For,11434037,147,119)
{
Start=1
Step=64
InData=0
link(onEvent,10749079:doCopy,[])
link(onStop,7070829:doTrim,[(194,132)(194,195)])
}
Add(Copy,10749079,203,119)
{
Count=64
link(onCopy,11002321:doStrCatDlm,[])
link(Str,4897077:Var3,[(209,96)])
}
Add(GetDataEx,4897077,98,91)
{
link(Data,13733457:Value,[])
}
Add(StrCatDelim,11002321,259,119)
{
Delimiter="\r\n"
Point(doClear)
link(Str1,3351435:Var3,[(265,107)(300,107)(300,166)])
}
Add(Trim,7070829,259,189)
{
Char="\r\n"
Mode=3
link(onTrim,4413279:doEvent1,[])
link(Text,3351435:Var2,[])
}
Add(Hub,4413279,308,189)
{
link(onEvent1,15700352:onEvent1,[(331,195)(331,48)])
link(onEvent2,11002321:doClear,[(331,202)(331,234)(247,234)(247,132)])
}
Add(GetDataEx,3351435,259,161)
{
link(Data,11002321:Result,[])
}
Add(Charset,5609255,42,42)
{
Type=5
link(onCharset,13733457:doValue,[])
}
END_SDK
Add(Hub,9631313,546,399)
{
link(onEvent1,1783972:doText,[])
link(onEvent2,14679024:doString,[(570,412)(570,440)])
}
Add(Hub,10874847,546,497)
{
link(onEvent1,8334407:doText,[])
link(onEvent2,14741656:doString,[(570,510)(570,538)])
}
Add(MT_MultiData,7596516,371,399)
{
link(onData1,10675047:doEnCrypt,[])
link(onData2,10789613:doWork1,[(429,412)(429,503)])
}
Add(FileStream,14988446,707,420)
{
Mode=1
AutoCopy=0
Point(doCopyFromStream)
link(FileName,11926105:GetData,[])
}
Add(FileStream,6992841,693,518)
{
Mode=1
AutoCopy=0
Point(doCopyFromStream)
link(FileName,6682603:GetData,[])
}
Add(StreamConvertor,7879394,637,434)
{
Mode=7
link(onResult,14988446:doCopyFromStream,[])
}
Add(StreamConvertor,14198454,637,532)
{
Mode=7
link(onResult,6992841:doCopyFromStream,[])
}
Add(FormatStr,14679024,581,434)
{
DataCount=1
Mask="-----BEGIN KEYPAIR-----\r\n%1\r\n-----END KEYPAIR-----"
link(onFString,7879394:doConvert,[])
}
Add(FormatStr,14741656,581,532)
{
DataCount=1
Mask="-----BEGIN PUBLICKEY-----\r\n%1\r\n-----END PUBLICKEY-----"
link(onFString,14198454:doConvert,[])
}
Add(GetDataEx,3297229,658,112)
{
link(Data,2682454:Text,[])
}
Add(EventFromData,11926105,707,357)
{
link(onEvent,6518011:doStrCat,[])
}
Add(StrCat,6518011,763,357)
{
Str2="_2.kpr"
link(onStrCat,11926105:doData,[(807,363)(807,351)(695,351)(695,363)])
link(Str1,5326159:Var3,[(769,327)])
}
Add(GetDataEx,16263063,287,322)
{
link(Data,5634174:Value,[])
}
Add(EventFromData,6682603,693,469)
{
link(onEvent,3783136:doStrCat,[])
}
Add(StrCat,3783136,749,469)
{
Str2="_2.kpb"
link(onStrCat,6682603:doData,[(793,475)(793,463)(681,463)(681,475)])
link(Str1,5326159:Var2,[])
}
Add(GetDataEx,5326159,749,322)
{
Angle=3
link(Data,16263063:Var3,[])
}
Add(HubEx,13642401,210,301)
{
Angle=3
link(onEvent,4964915:doWork3,[])
}
Add(HubEx,9039266,203,294)
{
Angle=3
link(onEvent,827949:doWork3,[])
}
Add(HubEx,10954523,210,182)
{
link(onEvent,11251377:doWork1,[(354,188)])
}
Add(HubEx,2828987,203,175)
{
link(onEvent,9632686:doClear,[(413,181)(413,286)])
}
Add(HubEx,4964915,210,217)
{
Angle=3
link(onEvent,10954523:doWork3,[])
}
Add(HubEx,827949,203,210)
{
Angle=3
link(onEvent,2828987:doWork3,[])
}
Add(DeCrypt,12655247,651,140)
{
Mode=4
link(Key,3297229:Var2,[])
}
Add(EnCrypt,10675047,455,399)
{
Mode=4
link(onEnCrypt,9306811:doWork1,[])
link(Key,3297229:Var1,[(468,117)])
}
BB-code статьи для вставки
Всего комментариев: 0
(комментарии к статье еще не добавлены)