Skip to main content

Posts

Starting with Basic File Cryptography (XOR Cipher)

  In this blog post, I'll discuss one interesting basic cipher technique to garble a file: The "XOR Cipher". What it does is obviously apply XOR (outputs true if both inputs are different) function for every bytes.   It's not rocket-science like other more sophisticated algorithms like AES, DES, or Blowfish; but adequate for blazingly-fast-low-level-security encryption.   The snippets I will show you adds a little twist. We will only encrypt the first 512 bytes of the file so that our code is scalable for larger files. The code: Some test:
Recent posts

Reading File MIME Type

  What I'm about to share with you covers basic MIME type reading. In some cases, you don't want to use additional external libraries for your project. For this simple task, using readily available classes on Java is always a joy.   Take extra care because not all commonly known MIME types are supported. I will show you that on the last part. Let's start. The code: Some Test: What else you need to know? The list of supported MIME types are located on your JRE. Locate the file named  content-types.properties at <JRE>/lib directory.  This file is being read by sun.net.www.MimeTable class which happens to be an implementation of java.net.FileNameMap. And, the default instance returned by URLConnection.getFileNameMap() function.