Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RSA Implement
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Chen-Lin Yu
April 24, 2013
80
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RSA Implement
RSA Algorithm
Chen-Lin Yu
April 24, 2013
Featured
See All Featured
A better future with KSS
kneath
240
18k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
630
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
560
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
750
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
Optimising Largest Contentful Paint
csswizardry
37
4k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
820
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.2k
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
360
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Transcript
RSA Implement Department of Computer Science & Information Engineering National
Kaohsiung University of Applied Sciences Chen-Lin Yu (1098108145) 2013.04.24
Outline Algorithm Flow Chart Result of Execution
Code
Algorithm Three steps: key generation, encryption and decryption. Key
generation: 1. 隨意選擇兩個大的質數p和q,p不等於q,計算N=pq。 2. 根據歐拉函數,求得r=(p-1)(q-1) 3. 選擇一個小於r的整數e,求得e關於模r的MOD運算,命名為d。(模反元素存在, 若且唯若e與r互質) 4. 將p和q的記錄銷毀。 5. (N,e)是公鑰(Public key),(N,d)是私鑰(Private key)
Algorithm Encryption : 假設Bob想給Alice送一個消息m,他知道Alice產生的N和e(Public key)。他使用起先 與Alice約好的格式將m轉換為一個小於N的整數n,比如他可以將每一個字轉換為這個 字的Unicode碼,然後將這些數字連在一起組成一個數字。假如他的信息非常長的話, 他可以將這個信息分為幾段,然後將每一段轉換為n。用下面這個公式他可以將n加密 為c:
計算c並不複雜。Bob算出c後就可以將它傳遞給Alice。
Algorithm Decryption : Alice得到Bob的消息c後就可以利用她的密鑰d來解碼。她可以用以下這個公式來將c 轉換為n: 得到n後,她可以將原來的信息m重新復原。
Flow Chart Alice Generate Asymmetric Key Provide Public Key Bob
Get Public Key of Alice Encrypt Data Alice Private Key to Decrypt Data Data Data
Result of Execution Generate key Encrypt Data Decrypt Data
Code //CspParameters Class new keycontainer and store key public static
void initialParameter() { const int PROVIDER_RSA_FULL = 1; const string CONTAINER_NAME = "SpiderContainer"; CspParameters cspParams; cspParams = new CspParameters(PROVIDER_RSA_FULL); cspParams.KeyContainerName = CONTAINER_NAME; cspParams.Flags = CspProviderFlags.UseMachineKeyStore; cspParams.ProviderName = "Microsoft Strong Cryptographic Provider"; rsa = new RSACryptoServiceProvider(cspParams); }
Code //CspParameters Class new keycontainer and store key public void
GenerateKey() { initialParameter(); //provide public & private Key RSA 物件的金鑰 string Key = rsa.ToXmlString(true); this.textBox6.Text = Key; //provide public key string publicKey = rsa.ToXmlString(false); this.textBox7.Text = publicKey; }
Code // EncryptData public string EncryptData (string data2Encrypt) { initialParameter();
string publickey = this.textBox8.Text; rsa.FromXmlString(publickey); //加解密都是以byte[],要將資料轉成byte[] byte[] plainbytes = System.Text.Encoding.UTF8.GetBytes(data2Encrypt); byte[] cipherbytes = rsa.Encrypt(plainbytes, false); return Convert.ToBase64String(cipherbytes); //array 轉回字串base 64編碼->此即為秘文(ciphertext) }
Code // DecryptData public string DecryptData (string data2Decrypt) { initialParameter();
byte[] getciphertext = Convert.FromBase64String(data2Decrypt); string privatekey = this.textBox6.Text; //從 XML 字串的金鑰資訊初始化 RSA 物件。 rsa.FromXmlString(privatekey); // decrypt ciphertext byte[] plain = rsa.Decrypt(getciphertext, false); return System.Text.Encoding.UTF8.GetString(plain); }
End, Thanks for your listening