SlideShare une entreprise Scribd logo
1  sur  5
Télécharger pour lire hors ligne
2014/2/23

Cocoa

#27 QuickLook

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html

1/5
2014/2/23

Cocoa

#27 QuickLook

$ ech o 'MacBook Air' | open s s l bf -e -k apple2 -ou t tes t.en c
$ h exdu m p -C tes t.en c
00000000 53 61 6c 74 65 64 5f 5f 09 40 94 44 e3 d9 23 71 |Salted__.@.D??#q|
00000010 9d e9 86 7f 3b 62 e1 80 09 5e 2f a4 b4 8d 7e 7e |.?..;b?..^/??.~~|
00000020
$ ech o 'MacBook Air' | open s s l bf -k apple2 -ou t tes t2 .en c
$ h exdu m p -C tes t2 .en c
00000000 53 61 6c 74 65 64 5f 5f b2 04 99 d5 48 5e 28 b7 |Salted__?..?H^(?|
00000010 2e 42 9c 15 83 25 6a 39 e5 1b f7 a6 2c 85 c9 a5 |.B...%j9?.??,.ɥ|
00000020
$ open s s l bf -d -k apple2 -in tes t.en c
MacBook Air

$ open s s l bf -P -k apple2
salt=17731E3E93896C77
key=3C27DE1D1DD84C0FA67B6A49E423DF4A
iv =B7FBF5536765B277
$ ech o 'MacBook Air' | open s s l bf -e -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7 -ou t tes t3 .en c
$ h exdu m p -C tes t3 .en c
00000000 25 d0 54 e1 59 fa 67 11 13 16 32 7a c8 87 b6 8b |%?T?Y?g...2z?.?.|
00000010
$ ech o 'MacBook Air' | open s s l bf -e -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7 -ou t tes t4 .en c
$ h exdu m p -C tes t4 .en c
00000000 25 d0 54 e1 59 fa 67 11 13 16 32 7a c8 87 b6 8b |%?T?Y?g...2z?.?.|
00000010
$ open s s l bf -in tes t3 .en c -d -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7
MacBook Air

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html

2/5
2014/2/23

Cocoa

#27 QuickLook

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html

3/5
2014/2/23

Cocoa

#27 QuickLook

#import "AppController.h"
@implementation AppController
- (void)awakeFromNib
{
NSString *rPath = [[NSBundle mainBundle] resourcePath];
NSString *encFile = [rPath stringByAppendingPathComponent:@"data.enc"];
/*
$ openssl bf -P -k apple2
salt=17731E3E93896C77
key=3C27DE1D1DD84C0FA67B6A49E423DF4A
iv =B7FBF5536765B277
*/
NSData* encData = [NSData dataWithContentsOfFile: encFile];
NSString* originalString = [[NSString alloc]initWithData: encData encoding: NSASCIIStringEncoding];
[originalText insertText: originalString];
int plainlen, tmplen;
unsigned char iv[8] = {0xB7, 0xFB, 0xF5, 0x53, 0x67, 0x65, 0xB2, 0x77};
unsigned char key[16] = {0x3C, 0x27, 0xDE, 0x1D, 0x1D, 0xD8, 0x4C, 0x0F,
0xA6, 0x7B, 0x6A, 0x49, 0xE4, 0x23, 0xDF, 0x4A};
unsigned char* inData;
unsigned char* outData;
inData = (unsigned char*)[encData bytes];
int inDataLen = [encData length];
outData = malloc(inDataLen + 8);
EVP_CIPHER_CTX ctx;
EVP_CIPHER_CTX_init( &ctx );
EVP_DecryptInit( &ctx, EVP_bf_cbc(), key ,iv );
int resultUpdate = EVP_DecryptUpdate( &ctx, outData, &plainlen, inData, inDataLen);
int resultFinal = EVP_DecryptFinal( &ctx, outData + plainlen, &tmplen);
EVP_CIPHER_CTX_cleanup(&ctx);
if ( ( resultFinal != 1 ) || ( resultUpdate != 1 ) )
{
[decriptedText insertText: @"Decription was not succeed." ];
} else {
outData[ plainlen + tmplen ] = 0;
NSString* decriptedString = [NSString stringWithUTF8String: (char*)outData];
[decriptedText insertText: decriptedString ];
}
free(outData);
}

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html

4/5
2014/2/23

Cocoa

#27 QuickLook

@end

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html

5/5

Contenu connexe

Similaire à Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号する

Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
Cis1-193-Rowe-Erin-exam 2 b(handson-lab)Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
erowe3
 
Topic 3 Green Design Links
Topic 3  Green  Design  LinksTopic 3  Green  Design  Links
Topic 3 Green Design Links
Jutka Czirok
 
Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1
ecommerce poland expo
 
BlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera APIBlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera API
Steven Beeckman
 
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docxSnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
jensgosney
 
Open Access publikācijas (2010. gada oktobris)
Open Access publikācijas (2010. gada oktobris)Open Access publikācijas (2010. gada oktobris)
Open Access publikācijas (2010. gada oktobris)
Bibliotēku portāls
 
Tenha um domínio do regedit do windows
Tenha um domínio do regedit do windowsTenha um domínio do regedit do windows
Tenha um domínio do regedit do windows
Carlos Catanejo
 

Similaire à Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号する (20)

Cocoa勉強会#27-QuickLookプラグインの作り方
Cocoa勉強会#27-QuickLookプラグインの作り方Cocoa勉強会#27-QuickLookプラグインの作り方
Cocoa勉強会#27-QuickLookプラグインの作り方
 
E portfolio design
E portfolio designE portfolio design
E portfolio design
 
E portfolio design
E portfolio designE portfolio design
E portfolio design
 
Cities: Input / Output, Thursday Night Lectures
Cities: Input / Output, Thursday Night LecturesCities: Input / Output, Thursday Night Lectures
Cities: Input / Output, Thursday Night Lectures
 
Buggi (2).pdf
Buggi (2).pdfBuggi (2).pdf
Buggi (2).pdf
 
How Endpoint Mobility Kills Bare Metal Restore (infographic)
How Endpoint Mobility Kills Bare Metal Restore (infographic)How Endpoint Mobility Kills Bare Metal Restore (infographic)
How Endpoint Mobility Kills Bare Metal Restore (infographic)
 
Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
Cis1-193-Rowe-Erin-exam 2 b(handson-lab)Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
 
Piwik elasticsearch kibana at OSC Tokyo 2016 Spring
Piwik elasticsearch kibana at OSC Tokyo 2016 SpringPiwik elasticsearch kibana at OSC Tokyo 2016 Spring
Piwik elasticsearch kibana at OSC Tokyo 2016 Spring
 
Cocoa勉強会#23-カスタムシートとModality
Cocoa勉強会#23-カスタムシートとModalityCocoa勉強会#23-カスタムシートとModality
Cocoa勉強会#23-カスタムシートとModality
 
Topic 3 Green Design Links
Topic 3  Green  Design  LinksTopic 3  Green  Design  Links
Topic 3 Green Design Links
 
hotfile june 16 2012
hotfile june 16 2012hotfile june 16 2012
hotfile june 16 2012
 
Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1
 
Functional Reactive Programming on Android
Functional Reactive Programming on AndroidFunctional Reactive Programming on Android
Functional Reactive Programming on Android
 
Introducing Intelligence Into Your Malware Analysis
Introducing Intelligence Into Your Malware AnalysisIntroducing Intelligence Into Your Malware Analysis
Introducing Intelligence Into Your Malware Analysis
 
BlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera APIBlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera API
 
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docxSnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
 
Open Access publikācijas (2010. gada oktobris)
Open Access publikācijas (2010. gada oktobris)Open Access publikācijas (2010. gada oktobris)
Open Access publikācijas (2010. gada oktobris)
 
Tenha um domínio do regedit do windows
Tenha um domínio do regedit do windowsTenha um domínio do regedit do windows
Tenha um domínio do regedit do windows
 
AtlasCamp 2015 Docker continuous integration training
AtlasCamp 2015 Docker continuous integration trainingAtlasCamp 2015 Docker continuous integration training
AtlasCamp 2015 Docker continuous integration training
 
Cadence Monte Carlo Simulation Tutorial
Cadence Monte Carlo Simulation TutorialCadence Monte Carlo Simulation Tutorial
Cadence Monte Carlo Simulation Tutorial
 

Plus de Masayuki Nii

Plus de Masayuki Nii (20)

Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
 
トップエスイー勉強会2014第1回-INTER-Mediator
トップエスイー勉強会2014第1回-INTER-Mediatorトップエスイー勉強会2014第1回-INTER-Mediator
トップエスイー勉強会2014第1回-INTER-Mediator
 
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみるCocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
 
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
 
Cocoa勉強会#61-メインスレッド外でNSURLConnection
Cocoa勉強会#61-メインスレッド外でNSURLConnectionCocoa勉強会#61-メインスレッド外でNSURLConnection
Cocoa勉強会#61-メインスレッド外でNSURLConnection
 
Cocoa勉強会#6-SQLiteをCocoaで使う
Cocoa勉強会#6-SQLiteをCocoaで使うCocoa勉強会#6-SQLiteをCocoaで使う
Cocoa勉強会#6-SQLiteをCocoaで使う
 
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
 
Cocoa勉強会#57-Baseによるローカライズまとめ
Cocoa勉強会#57-BaseによるローカライズまとめCocoa勉強会#57-Baseによるローカライズまとめ
Cocoa勉強会#57-Baseによるローカライズまとめ
 
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しないCocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
 
Cocoa勉強会#45-AWS SimpleDBを使ってみる
Cocoa勉強会#45-AWS SimpleDBを使ってみるCocoa勉強会#45-AWS SimpleDBを使ってみる
Cocoa勉強会#45-AWS SimpleDBを使ってみる
 
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビューCocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
 
Cocoa勉強会#33-意外に楽に使えるlibcurl
Cocoa勉強会#33-意外に楽に使えるlibcurlCocoa勉強会#33-意外に楽に使えるlibcurl
Cocoa勉強会#33-意外に楽に使えるlibcurl
 
Cocoa勉強会23-識別情報の変換〜文字エンコードとデータタイプ
Cocoa勉強会23-識別情報の変換〜文字エンコードとデータタイプCocoa勉強会23-識別情報の変換〜文字エンコードとデータタイプ
Cocoa勉強会23-識別情報の変換〜文字エンコードとデータタイプ
 
Cocoa勉強会#37-シェイクイベントの実装
Cocoa勉強会#37-シェイクイベントの実装Cocoa勉強会#37-シェイクイベントの実装
Cocoa勉強会#37-シェイクイベントの実装
 
Cocoa勉強会#32-表形式のデータに順序を記録する方法
Cocoa勉強会#32-表形式のデータに順序を記録する方法Cocoa勉強会#32-表形式のデータに順序を記録する方法
Cocoa勉強会#32-表形式のデータに順序を記録する方法
 
Cocoa勉強会#35-iPhoneでのコピペとカスタムUI
Cocoa勉強会#35-iPhoneでのコピペとカスタムUICocoa勉強会#35-iPhoneでのコピペとカスタムUI
Cocoa勉強会#35-iPhoneでのコピペとカスタムUI
 
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
 
Cocoa勉強会#38-UITableViewテーブル内のナビゲーション
Cocoa勉強会#38-UITableViewテーブル内のナビゲーションCocoa勉強会#38-UITableViewテーブル内のナビゲーション
Cocoa勉強会#38-UITableViewテーブル内のナビゲーション
 
Cocoa勉強会#43-Blocksを使う
Cocoa勉強会#43-Blocksを使うCocoa勉強会#43-Blocksを使う
Cocoa勉強会#43-Blocksを使う
 
Cocoa勉強会#42-UIWebKitをコンポーネントとして使う
Cocoa勉強会#42-UIWebKitをコンポーネントとして使うCocoa勉強会#42-UIWebKitをコンポーネントとして使う
Cocoa勉強会#42-UIWebKitをコンポーネントとして使う
 

Dernier

Dernier (20)

Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxBT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 

Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号する

  • 2. 2014/2/23 Cocoa #27 QuickLook $ ech o 'MacBook Air' | open s s l bf -e -k apple2 -ou t tes t.en c $ h exdu m p -C tes t.en c 00000000 53 61 6c 74 65 64 5f 5f 09 40 94 44 e3 d9 23 71 |Salted__.@.D??#q| 00000010 9d e9 86 7f 3b 62 e1 80 09 5e 2f a4 b4 8d 7e 7e |.?..;b?..^/??.~~| 00000020 $ ech o 'MacBook Air' | open s s l bf -k apple2 -ou t tes t2 .en c $ h exdu m p -C tes t2 .en c 00000000 53 61 6c 74 65 64 5f 5f b2 04 99 d5 48 5e 28 b7 |Salted__?..?H^(?| 00000010 2e 42 9c 15 83 25 6a 39 e5 1b f7 a6 2c 85 c9 a5 |.B...%j9?.??,.ɥ| 00000020 $ open s s l bf -d -k apple2 -in tes t.en c MacBook Air $ open s s l bf -P -k apple2 salt=17731E3E93896C77 key=3C27DE1D1DD84C0FA67B6A49E423DF4A iv =B7FBF5536765B277 $ ech o 'MacBook Air' | open s s l bf -e -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7 -ou t tes t3 .en c $ h exdu m p -C tes t3 .en c 00000000 25 d0 54 e1 59 fa 67 11 13 16 32 7a c8 87 b6 8b |%?T?Y?g...2z?.?.| 00000010 $ ech o 'MacBook Air' | open s s l bf -e -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7 -ou t tes t4 .en c $ h exdu m p -C tes t4 .en c 00000000 25 d0 54 e1 59 fa 67 11 13 16 32 7a c8 87 b6 8b |%?T?Y?g...2z?.?.| 00000010 $ open s s l bf -in tes t3 .en c -d -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7 MacBook Air file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html 2/5
  • 4. 2014/2/23 Cocoa #27 QuickLook #import "AppController.h" @implementation AppController - (void)awakeFromNib { NSString *rPath = [[NSBundle mainBundle] resourcePath]; NSString *encFile = [rPath stringByAppendingPathComponent:@"data.enc"]; /* $ openssl bf -P -k apple2 salt=17731E3E93896C77 key=3C27DE1D1DD84C0FA67B6A49E423DF4A iv =B7FBF5536765B277 */ NSData* encData = [NSData dataWithContentsOfFile: encFile]; NSString* originalString = [[NSString alloc]initWithData: encData encoding: NSASCIIStringEncoding]; [originalText insertText: originalString]; int plainlen, tmplen; unsigned char iv[8] = {0xB7, 0xFB, 0xF5, 0x53, 0x67, 0x65, 0xB2, 0x77}; unsigned char key[16] = {0x3C, 0x27, 0xDE, 0x1D, 0x1D, 0xD8, 0x4C, 0x0F, 0xA6, 0x7B, 0x6A, 0x49, 0xE4, 0x23, 0xDF, 0x4A}; unsigned char* inData; unsigned char* outData; inData = (unsigned char*)[encData bytes]; int inDataLen = [encData length]; outData = malloc(inDataLen + 8); EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init( &ctx ); EVP_DecryptInit( &ctx, EVP_bf_cbc(), key ,iv ); int resultUpdate = EVP_DecryptUpdate( &ctx, outData, &plainlen, inData, inDataLen); int resultFinal = EVP_DecryptFinal( &ctx, outData + plainlen, &tmplen); EVP_CIPHER_CTX_cleanup(&ctx); if ( ( resultFinal != 1 ) || ( resultUpdate != 1 ) ) { [decriptedText insertText: @"Decription was not succeed." ]; } else { outData[ plainlen + tmplen ] = 0; NSString* decriptedString = [NSString stringWithUTF8String: (char*)outData]; [decriptedText insertText: decriptedString ]; } free(outData); } file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html 4/5