tag:blogger.com,1999:blog-55691354083525336212024-03-13T03:30:07.835-07:00TCD Computer Science Student's BlogSheogorahttp://www.blogger.com/profile/08441651099960398511noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-5569135408352533621.post-7794903139114717772013-06-14T06:27:00.001-07:002013-06-14T06:27:34.147-07:00E3: Xbox One VS PS4 opinionThe ultimate console wars! Has Xbox made a bad move? I was hoping to give my overview on the whole situation. I strongly believe that it is a draw. Here are my reasons:<br />
<br />
<ul>
<li>Even though the internet are all against Xbox because people tend to follow the bandwagon of hate phenomenon and yes the Xbox did not make it any less easier for themselves with their announcements. People will still buy the new console, it is just how it always is. Same situation happened with EA, people threatened to boycott it, but they still buy every single new game released. </li>
</ul>
<div>
<ul><a href="http://1.bp.blogspot.com/-xd7sXVOp54I/UZ6Fu8KMo9I/AAAAAAAAAWs/lJ6Ot1P8y0E/s1600/e3.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-xd7sXVOp54I/UZ6Fu8KMo9I/AAAAAAAAAWs/lJ6Ot1P8y0E/s320/e3.jpg" width="268" /></a>
<li>Considering the way Xbox completely eliminated second hand retailers from their systems, people will have no options but to buy the full game if they want to play it. This will result with the full price going to the Xbox and developers and no third party retailer. Even though they might lose a large part of the Xbox audience, it will mostly lose the people who only bought second hand games, thus this does not make a difference.</li>
</ul>
<ul>
<li>Sony on the other hand are openly admitting the freedom for their customers. Want to buy used game? We don't care, just buy our console please. Their overall gain from getting all of these new Xbox fans to buy their system will increase revenue but they will actually lose money to the developers. </li>
</ul>
<div>
No matter what, true die hard fans will fight you for their console. </div>
</div>
<div>
<br /></div>
<div>
Personally, I am a PC girl :D</div>
Sheogorahttp://www.blogger.com/profile/08441651099960398511noreply@blogger.com0tag:blogger.com,1999:blog-5569135408352533621.post-70374994429085808562013-06-14T01:15:00.000-07:002013-06-14T07:46:46.662-07:00GWT project experience<br />Recently I had to create a full working ground up project using the Google Web Toolkit Framework, so I thought I would give my feedback on the experience I had working with it. Take note, that I have previously worked with ASP .NET, Django, Spring Framework thus I will mostly compare it to these.<div class="separator" style="clear: both; text-align: center;">
<a href="https://lh4.googleusercontent.com/sGxF8nL6h8g1AFPOqdqL9ThtQVg7JJcqTUABFQyeV4nUCmR6tGK_mEZzmSNNHxSWJB1eqFOBrSmfAia6Txj0jJVtfBqUvIWQVUGrpwocqAIKY6FJV-FryPDgHq8" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://lh4.googleusercontent.com/sGxF8nL6h8g1AFPOqdqL9ThtQVg7JJcqTUABFQyeV4nUCmR6tGK_mEZzmSNNHxSWJB1eqFOBrSmfAia6Txj0jJVtfBqUvIWQVUGrpwocqAIKY6FJV-FryPDgHq8" /></a></div>
<div>
<br />As you may have noticed GWT is an open source development toolkit. The setup process of your very first working application is no longer than 5-10 minutes which is what I love about it. All you have to do is download the GWT plugin from the Eclipse Marketplace, restart Eclipse, right-click create new GWT project and check to generate sample code. The most basic application will be set up for you. Right click your project to run in DevMode and open a browser for you application. How great is that?<br /><br /> When you get over the fact of how easy it is to test your application and that all the things you need are already set up for you and you do not have to fiddle with web.xml or GWT libraries. Next step is to play around with some of the amazing features GWT offers by going to their Showcase web page where they offer a preview of how the certain widget looks like but also the code to get it to work. <br /><br />One of the things that struck me as abnormal to the original way of developing web pages is the fact that GWT only needs 1 .html page. Everything inside this page is assigned dynamically using pure java code. In case you have a page full of buttons and you do not want to spend millions of lines of code declaring every single “Button button1 = new Button();” all you have to do is look up UiBinder where all of these widgets will be declared using a well structured xml document. Great huh?<br /><br />I outlined how pretty and simple GWT makes dynamic web page creation, but with every view there is always a rant, so lets begin. GWT YOU ARE SO LIMITED! Sure all the widgets are great and all, but the amount of time I had to spend customising handlers and @Overriding these widgets to get them to do what I wanted is ridiculous. It was a constant battle of the wits. TextArea, a box for text, does NOT have a set for the maximum number of characters it accept. I had to create a javascript native method for pasting and a keyboard press handler to limit character input. Don’t even get me started on CellTable. I will make a tutorial at some point for the customisation of CellTable to your needs, mostly because I spent so much time at it that I do not want to waste it.<br /><br /> You might start asking me, “well, if you think GWT is so limited why not just download something like smartgwt or gxt which have many more features?” well sir, my answer to you is: did you see the size of the libraries for those things? I do not want to use all the features... Why can’t I make several simple parameter setups for the current GWT widgets instead?<br /><br />Don’t get me wrong, GWT is fun and great, but it doesn’t teach you much about proper web development setup. If you are new and want to try something quick I would suggest GWT, if you have a more serious project and you want GWT go with GXT even though I see a lot of people complaining about its features breaking peoples applications. <br /><br /><b> TL;DR : With great power (like GWT), comes great programmability.</b><br /><br /> <br /><br /><br /><b id="docs-internal-guid-5bac766f-41be-6cde-f52f-eeab9e8a0627">
</b></div>
Sheogorahttp://www.blogger.com/profile/08441651099960398511noreply@blogger.com0tag:blogger.com,1999:blog-5569135408352533621.post-86808276441344358702013-01-25T17:19:00.002-08:002013-06-14T06:29:54.702-07:00Weave Silk, interactive generative art<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-VocsXq6IahY/UQMuTiB98eI/AAAAAAAAAgk/1pLc0JMFt1U/s1600/cat.png" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="251" src="http://4.bp.blogspot.com/-VocsXq6IahY/UQMuTiB98eI/AAAAAAAAAgk/1pLc0JMFt1U/s400/cat.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-size: x-small;">My <a href="http://new.weavesilk.com/?s7vi" style="text-align: start;" target="_blank">Cat</a></span></td></tr>
</tbody></table>
<br />
Here is a little something I made using this interesting little tool for creating interactive art. The silk like art tools of multiple colors allow creating ambient designs while you listen to very relaxing music. Options exist for creating symmetric or non-symmetric art.<br />
I personally spent about an hour playing with this website. Every stroke along the canvas creates a work of art within itself. You don't have to be an artist to enjoy it. Link to the website <a href="http://new.weavesilk.com/" target="_blank">new.weavesilk.com</a><br />
<br />
<br />Sheogorahttp://www.blogger.com/profile/08441651099960398511noreply@blogger.com0tag:blogger.com,1999:blog-5569135408352533621.post-22483286280611888322013-01-25T12:58:00.001-08:002013-06-14T06:30:38.517-07:00'Whirled Worlds' the spinning plate interface<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/mQf89AR3Tbg?feature=player_embedded' frameborder='0'></iframe></div>
This has to be one of the most ridiculous applications I have seen for a phone/tablet. It is in fact so ridiculous that the only thing they could come up with to use it for is spinning it like a disc. Who in their right mind would use an expensive device as a phone/tablet and mindlessly spins it around their house while attempting to play a pizzeria game. What's next? Skeet shooting?<br />
To read more about it - <a href="http://www.hotmobile.org/2012/papers/dandp/abstract.pdf" target="_blank">Abstract</a>Sheogorahttp://www.blogger.com/profile/08441651099960398511noreply@blogger.com0tag:blogger.com,1999:blog-5569135408352533621.post-82567038475490130792013-01-06T14:38:00.005-08:002013-06-14T06:31:23.612-07:00My favourite inventions of 2012<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/FFGfq0pRczY?feature=player_embedded' frameborder='0'></iframe><span style="font-family: Arial,Helvetica,sans-serif;"> </span></div>
<span style="font-family: Arial,Helvetica,sans-serif;"> I want to wish everyone a Happy 2013! Heres to hope this year will be full of fantastic inventions and research! I wanted to highlight a couple of my most favorite from 2012.</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"> DARPA's robot navigating an obstacle course. It is amazing what people can make out of algorithms, sensors and machine parts. This has to be my favorite artificial intelligence creation so far. The only concern with the high increase of robotic inventions in the world, is putting them for good use. Unlike ASIMO robot who is currently being used to deliver coffee at the Honda offices, robots like these could actually be utilized in dangerous environments where human involvement would prove fatal. </span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span>
<span style="font-family: Arial,Helvetica,sans-serif;">Another one of my favorite inventions is the Corning Willow Glass. With the current market highly invested in making applications smaller and lighter yet still maintaining their usefulness, this thin, light and cost efficient glass can greatly improve mobile devices.</span><br />
<div style="text-align: right;">
[<a href="http://www.corning.com/displaytechnologies/en/products/flexible.aspx" target="_blank">Source</a>]</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.corning.com/uploadedImages/Corporate/ww/Assets/Images/Flexible_Bend.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="http://www.corning.com/uploadedImages/Corporate/ww/Assets/Images/Flexible_Bend.jpg" width="200" /></a></div>
<br />Sheogorahttp://www.blogger.com/profile/08441651099960398511noreply@blogger.com0tag:blogger.com,1999:blog-5569135408352533621.post-34328928132568596082012-10-08T12:49:00.001-07:002013-06-14T06:32:08.859-07:00Build Your Skeletons CorrectlyI was working with character models that where using motion captured movements. Here are some results of incorrectly created character skeletons and why it is important to build them correctly!<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-w-2Ojzj7S3s/UHMtqIAkJOI/AAAAAAAAAfs/Skt6nNYC0eQ/s1600/282950_4083070992724_1929853241_n.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="378" src="http://1.bp.blogspot.com/-w-2Ojzj7S3s/UHMtqIAkJOI/AAAAAAAAAfs/Skt6nNYC0eQ/s400/282950_4083070992724_1929853241_n.jpg" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-SFBXVnmmgBs/UHMts880TrI/AAAAAAAAAgA/uFzYLFLXzcY/s1600/t.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-SFBXVnmmgBs/UHMts880TrI/AAAAAAAAAgA/uFzYLFLXzcY/s320/t.png" width="176" /></a><a href="http://4.bp.blogspot.com/-qKbckifROCM/UHMtrB8-7iI/AAAAAAAAAf0/MWbDgWT3JMY/s1600/h.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/-qKbckifROCM/UHMtrB8-7iI/AAAAAAAAAf0/MWbDgWT3JMY/s320/h.png" width="260" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-Nw2wXreAri0/UHMtsJAj9iI/AAAAAAAAAf4/gq_vAbzj37Q/s1600/skeleton.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="245" src="http://2.bp.blogspot.com/-Nw2wXreAri0/UHMtsJAj9iI/AAAAAAAAAf4/gq_vAbzj37Q/s400/skeleton.png" width="400" /></a></div>
<br />
<br />Sheogorahttp://www.blogger.com/profile/08441651099960398511noreply@blogger.com0tag:blogger.com,1999:blog-5569135408352533621.post-55241222860202932132012-03-23T15:10:00.000-07:002013-06-14T06:42:53.568-07:00M2Crypto for Python X509 certificates and RSA encryption<span style="font-size: x-small;">Don't you hate it when you cannot find a proper guide to use a certain programming language? I had this problem over the last week when I was trying to use encryption in python.</span><br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;">My task was to simulate 2 players playing a game of tic tac toe over a secure connection. By secure connection I mean, they had to get a certificate from a Certificate Authority, check its authenticity and extract a public key, with which they encoded data and sent to the other player. So If a certain nosy person decided to listen into the conversation he will not be able to decrypt the messages with a private key.</span><br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;">I coded a tic tac toe game using sockets and threads no problem. The main issue came in when I wanted to encode data and create a X509 certificate. A very commonly used library for certificate creation is called OpenSSL. Since I rather code on my windows machine, I was having a lot of trouble trying to install it. The alternative I looked at is called pyOpenSSL, it is python wrapper to call certain methods in OpenSSL using a few commands. This library was very limited and did not provide encryption and decryption. Which means I would have to import other libraries such as RSA. After looking helplessly I found a lovely thing called M2Crypto. The only problem with it is that It has very little documentation or sample code online on how to exactly execute certain things. I was mostly looking at Stack Overflow questions people made about problems. After a couple of days of struggling and messing around with code, I have done it.</span><br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;">I decided to create an easy readable manual on M2Crypto for people who decide to work on it. This will provide a set of commands which you might require to implement a secure connection.</span><br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;"><b id="internal-source-marker_0.3861820523161441"></b></span><br />
<h3 style="text-align: center;">
<span style="font-size: x-small;"><b id="internal-source-marker_0.3861820523161441"><span style="font-family: Arial; vertical-align: baseline; white-space: pre-wrap;">M2Crypto</span></b></span></h3>
<span style="font-size: x-small;"><b id="internal-source-marker_0.3861820523161441"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">M2Crypto download:</span><br /><a href="http://chandlerproject.org/Projects/MeTooCrypto#Downloads"><span style="color: #1155cc; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">http://chandlerproject.org/Projects/MeTooCrypto#Downloads</span></a><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span><br /><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span><br /><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">To import M2Crypto into code:</span><br /><span style="color: #3c78d8; font-family: Consolas; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">import M2Crypto</span></b></span><br />
<span style="font-size: x-small;"><b><span style="color: #3c78d8; font-family: Consolas; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"><br /></span></b></span>
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">Importing certain libraries:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">from M2Crypto import RSA, EVP</span><br />
<span style="font-size: x-small;"><span style="color: #0c343d; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">Generating a Random RSA key pair (public and private):</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">key= RSA.gen_key(512, 65537)</span><br />
<span style="font-size: xx-small;"><span style="font-family: Arial; font-style: italic; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">512 is the size of the key</span><br /><span style="font-family: Arial; font-style: italic; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">65537 encryption standard use it as a default</span></span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">Saving the generated public and private key:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">key.save_key ('Alice-private.pem', None)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">key.save_pub_key ('Alice-public.pem')</span><br />
<span style="font-size: xx-small;"><span style="font-family: Arial; font-style: italic; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">None is a specified password for testing purposes there is none</span><br /><span style="font-family: Arial; font-style: italic; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">The file can be created in a specific directory ‘/local/temp/Alice-private.pem’</span></span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">Converting the RSA key into a PKey() which is stored in a certificate:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">pkey = EVP.PKey()</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">pkey.assign_rsa(key)</span><span style="font-size: x-small;"><span style="color: #3c78d8; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">To create a X509 certificate using M2Crypto:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"># time for certificate to stay valid</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cur_time = M2Crypto.ASN1.ASN1_UTCTIME()</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cur_time.set_time(int(time.time()) - 60*60*24)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">expire_time = M2Crypto.ASN1.ASN1_UTCTIME()</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"># Expire certs in 1 hour.</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">expire_time.set_time(int(time.time()) + 60 * 60 * 24)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"># creating a certificate</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cert = M2Crypto.X509.X509()</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cert.set_pubkey(pkey)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cs_name = M2Crypto.X509.X509_Name()</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cs_name.C = "US"</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cs_name.CN = “8080”</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cs_name.Email = "fake@foo.com"</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cert.set_subject(cs_name)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cert.set_issuer_name(cs_name)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cert.set_not_before(cur_time)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cert.set_not_after(expire_time)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"># self signing a certificate</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cert.sign(pkey, md="sha256")</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">cert.save_pem("cert")</span><br />
<span style="font-size: x-small;"><span style="color: #3c78d8; font-family: Consolas; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">This will create a “cert” file in your directory which can be loaded later on. Or you can use the cert object to convert into a string to send it through a socket EG:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">message = cert.as_pem()</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">print message</span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">Printing the certificate as a pem will look something like this, which is stored in a cert file if you open it with notepad:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">-----BEGIN CERTIFICATE-----</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">MIIBYzCCAQ0CADANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQGEwJVUzENMAsGA1UE</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">AxMEODA4MTEfMB0GCSqGSIb3DQEJARYQZmFrZUBob3RtYWlsLmNvbTAeFw0xMjAz</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">MjEyMTU0MTJaFw0xMjAzMjMyMTU0MTJaMD0xCzAJBgNVBAYTAlVTMQ0wCwYDVQQD</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">EwQ4MDgxMR8wHQYJKoZIhvcNAQkBFhBmYWtlQGhvdG1haWwuY29tMFwwDQYJKoZI</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">hvcNAQEBBQADSwAwSAJBANFx5xZ/4k5Rx2XeAHrFLkaswFa8DIak1JnEMB+epKei</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">KNKrGliibUYp74YDAMw9CpA1QPzFqYKz7/zTivteSSkCAwEAATANBgkqhkiG9w0B</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">AQsFAANBALFh3S7rNMN/mYcmJzQQfe/FEEpVc0esRbeL/hvwWZs1C4yj+MwpCgBi</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">P/zSzkglB3WHe2VZk5i7kKv1pN+qvdU=</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">-----END CERTIFICATE-----</span><br />
<span style="font-size: x-small;"><span style="color: #3c78d8; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">Once you receive the certificate as a string the way to convert it to a certificate object is:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">m2cert = M2Crypto.X509.load_cert_string(message)</span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">you can print the certificate object as a more readable string with this line:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">print m2cert.as_text()</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">Certificate:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Data:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Version: 1 (0x0)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Serial Number: 0 (0x0)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Signature Algorithm: sha256WithRSAEncryption</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Issuer: C=US, CN=8081/emailAddress=fake@hotmail.com</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Validity</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Not Before: Mar 21 22:16:06 2012 GMT</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Not After : Mar 23 22:16:06 2012 GMT</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Subject: C=US, CN=8081/emailAddress=fake@hotmail.com</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Subject Public Key Info:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Public Key Algorithm: rsaEncryption</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> RSA Public Key: (512 bit)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Modulus (512 bit):</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> 00:c6:02:10:81:5d:c5:a4:30:83:24:91:ce:78:86:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> 7b:47:ea:20:02:ab:07:bc:91:39:7d:c1:5b:2c:3a:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> e3:9c:b6:6a:96:86:9c:7e:e4:c8:6c:a9:8c:b1:33:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> c6:1c:20:8c:cd:05:3e:b1:4b:69:49:9a:6c:0b:14:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> a9:52:25:8d:47</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Exponent: 65537 (0x10001)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> Signature Algorithm: sha256WithRSAEncryption</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> 67:59:f6:04:a4:21:8b:8e:ff:f9:6a:79:56:13:b9:cb:84:24:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> 9e:cd:b0:d7:c0:76:4f:99:bc:0f:14:f5:76:2a:07:04:c6:dc:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> be:56:c1:68:5b:35:4e:f2:c7:b4:5b:ac:c9:c3:d9:a1:c1:d5:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"> 73:52:9b:e2:36:45:ba:9b:a4:02</span><br />
<span style="font-size: x-small;"><span style="color: #3c78d8; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">To extract an RSA key which can be used for encoding you use this:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">pkey= m2cert.get_pubkey()</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">rsa_key_pub = pkey.get_rsa()</span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">to encrypt a message using the public key above:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">crypto = rsa_key_pub.public_encrypt(message, M2Crypto.RSA.pkcs1_oaep_padding)</span><br />
<span style="font-family: Arial; font-style: italic; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"><span style="font-size: xx-small;">M2Crypto.RSA.pkcs1_oaep_padding this is a RSA encryption type, there are different ones, but you should stick to one if you do not want to bother having to extract the type from the RSA key.</span></span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">to decrypt a message using the private key, which you saved earlier, you need to load it first:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">rsa_key_pri= M2Crypto.RSA.load_key(‘Alice-public.pem’)</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small;"><span style="white-space: pre-wrap;"><br /></span></span><span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">once loaded use the command to decrypt:</span><br />
<span style="color: #3c78d8; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">decyphered = rsa_key.private_decrypt(message, M2Crypto.RSA.pkcs1_oaep_padding)</span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<div style="text-align: center;">
<u style="font-family: Arial; font-size: small; white-space: pre-wrap;"><b>If you have any of the following errors:</b></u></div>
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="background-color: yellow; font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">RSAError: data too large for modulus</span><br />
<span style="font-size: x-small;"><span style="font-family: Consolas; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">Check to make sure the data you are encrypting does not exceed the formula:</span><br />
<span style="font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">(sizeofkey/8) - 11 bytes</span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">If it is then you will have to cut the message into slices and encrypt it OR encrease the size of the RSAKey</span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">512 - moderate secure</span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">1024 - really secure</span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">2048 - military security</span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">The bigger size of the key, the longer it will take to generate it.</span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="background-color: yellow; font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">RSAError: no start line</span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">You are using the wrong file name or format for example if you open the .pem file for one of your private or public keys the header will say something like this:</span><br />
<span style="font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">-----BEGIN RSA PRIVATE KEY-----</span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">or</span><br />
<span style="font-family: Consolas; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">-----BEGIN PUBLIC KEY-----</span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">you need to make sure the file you are using is correct and you are not trying to encrypt using a private key or vice versa</span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="background-color: yellow; font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">RSAError: oaep decoding error</span><br />
<span style="font-size: x-small;"><span style="font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;"></span></span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">This means that during the method decrypt, you have used the wrong private key. The error means that the decryption that you get from decrypting the message is not the same as original one.</span><br />
<span style="font-family: Arial; font-size: x-small; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;">Make sure you are using correct keys it is easy to mix them up </span><span style="font-size: x-small;"> </span>Sheogorahttp://www.blogger.com/profile/08441651099960398511noreply@blogger.com0