Long time, no see.
I decided to give a more insight in more programming for the viewer’s sake.
Following are the projects and definition also follows.
For Java Realm:
CryptoServices in Java: CRCPro
CryptoServices in Java: CryptoPro
CryptoServices in Java: FileOperatorPro
CryptoServices in Java: HibernatePro
CryptoServices in Java: JAX-WS-RPC
Click for the public github link for the Java Realm
For .NET Realm:
CryptoServices in .NET: CRC32
CryptoServices in .NET: 3DES
CryptoServices in .NET: CryptoServiceLibrary and WCF
CryptoServices in .NET: EDMDAL – Entity Framework
CryptoServices in .NET: Hosting the service and Client
Click for the public github link for the .NET Realm
Above projects are pretty moderate in which they represent the pseudo-backend implementation. Yet, these 2 projects should be modular enough so that viewer’s can run seperately. There are 2 techs utilized mainly, good old Java and arrogant, yet powerful .NET. I don’t believe in a omnipotent technology so I will share both my views as impartial as possible.
The program has the main idea of a client sending file content or path and the request of encryption and decryption is handled in server, and server propogates the file path or sometimes file content in db. Now, I used too many “or”s, that’s because the projects are not exact replica of each other. They are similar but not the same. I did like that as I want you to understand what happens, when and why you should and moreover, shouldn’t use that approach. You will get this while reading the further posts.
Note that, I haven’t used bouncycastle libraries in noone of the projects. You can check some bouncycastle approach in other posts in this blog.
Also, .NET project utilizes the instances of MSSQL 2008 R2 whereas Java utilizes MySQL.
Ok, here is the scope of the complete modules of the program in Java and .NET.
Important note: You have to have Java7, otherwise you will have problems
Java Realm (Don’t mind the project naming :):
Calculation of CRC for a given file.
DES symmetric encryption which is known for its weakness :), but for the sake of introduction to cryptography, it’s a good start. Well, I won’t be giving any explanation about DES. Google it.
A simple FileOperation mediator design.
A simple Hibernate ORM design.
JAX-WS RPC style service with a java client.
This is the Java Realm of the workspace folder. So, there is no single project having different packages. Rather, different projects and you have to add the first 4 project to 5. project’s build path. To do that, simply go to the build path of module/project 5 and add the other 4 there.
The complete hierarchy of the projects are given below:
Don’t mind the naming convention for the projects.
For .NET equivalent, let’s give me some technical background.
There is a Crypto solution for .NET equivalent, and it has 6 projects in it.
CRC32: calculation CRC and surprisingly, .NET has no built-in class for CRC calculation. Interesting..
3DES: crypting a file with 3DES and in CBC block cipher.
CryptoServiceLibrary: A WCF service for operations and generation of wsdl.
EDMDAL: EF ORM utilization.
Client: A console client requesting the service.
ConsoleHost: A console host, hosting the service.
Below is the hierarchy:
Now, most of the bloggers or programmers gave the code directly, but let me give a couple of notes and relaying some experience, regarding the projects. So that, you can have some pre-warnings before executions.
CRCPro: It was straight forward. I also utilized a cool Java 7 feature (which .NET has already had a similar before).
CryptoPro: Careful about BOM in a file content, while decrypting a file. A BOM is represented as ï»¿ and it may appear in the start or mid of the file content. Encoding is utmost important in this context. My code is working on UTF-8 and the resource file is also UTF-8 encoded.
In this project, I also used apache commons approach for a file operation.
It’s also straight forward file operation mediator project. I could have actually designed this better but I did all those in a couple of hours, so the design may be underrated.
In this project, also you can see a unique generation that you can use in your other projects.
This is just for ORM mapping and you can check for this in detail soon. I always liked Hibernate, yet, I am not a big fan of XML configuration files. I could have used Annotation based approach but I prefer XML configuration files. Note that it is sometimes inevitable..
My recommendation is that be really careful while forming your XML configuration file. The debugging is sometimes really hard once you have a misformed XML configuration. Always validate the XML. You are safe if you are using a known editor like notepad++ or oXygen.
I assume that you are using Eclipse as in this post. Please do so, eclipse, rational, netbeans or any other.
This project doesn’t contain a really complex HQL approach. I can dig for a deeper approach for HQL in a later post.
Simple JAX-WS over RPC. I am not a fan of wsdl but Oracle really knows the drift for easy implementation with annotations. I really prefer this SOAP, XML over HTTP sometimes.
Anyway, drift is simple, you have a server instance publishing a service, and a consumer consumes the service via wsdl spec.
This project also contains a client which is a consumer as said. I implemented the client in Java but guess what, I will implement another one in PHP and .NET clients just for you to see how “this” service is consumed.
I must say I feel a little safer during the implementation of this 3DES&CBC implementation in .NET. It uses CryptoStream class and extremely straight forward.
This project was extremely painful. I think we need an actual CRC implementation in .NET 5. (Sad that, .NET 4.5 has upgrades for multithreading only).
This is the WCF service that publishes the encryption and decryption with a wsdl file. The communication is via simply HTTP binding. I could also have implemented this as an mere web service as in Java but I chose not to. Also, RMI equivalent .NET Remoting is no longer welcomed in .NET premises. For one reason, the marshalling and unmarshalling is extremely complicated in .NET Remoting and it has a terrible restriction as both the service publisher and consumers must exist in the same gateway!! I think It’s a nice move by Microsoft to develop WCF Framework. Note that WCF’s debugging is extremely powerful which is a plus
This is the EF-ORM project, equivalent of Hibernate. Although I love the approach, I still prefer manual Hibernate approach. For one reason, there is a dreadful problem in .NET when EF and WCF are utilized together. The connection string in application configuration file is not propogating in projects, so i had to copy connection string in App.config file in EDMDAL project and paste it to WCF’s App.config, but worse, I had to edit the edmx file manually as .NET framework was stubborn to grab the connection string.
The Java projects are in the github in a public repository, https://github.com/jazziiilove/Crypto-Java