Tuesday, February 24, 2015

Hashing with LibreOffice

For a project, I needed to hash some data from a spreadsheet.
I'm using LibreOffice Calc ( for Windows - for Linux) and there is no direct support for the hash.

Let see how is possible to obtain the hash using LibreOffice Calc.

Cryptographic extension

It is available a third party extension that supports the hash.

I didn't find much direct and clean information about how to use it, so here my experience with it.


  • Download the file cryptographic.oxt from the link
  • Open LibreOffice Calc
  • Go on Tools/Extension Manager
  • Add the extension downloaded
  • Create a macro to support the extension
To create the macro, follow these steps :
  • Go on the Tools/Macros/Organize Macros/LibreOffice Basics
  • Select MyMacros
  • Click on the New button
  • Copy this macro (available in the file on the same link) :
REM Propósito: Computes hashes (message digests) of text and files using following hashing algorithms: MD2, MD5, SHA-1, SHA-256, SHA-384 and SHA-512
REM Informações sobre o Módulo: Módulo Padrão = basMain
REM Convenção para nomeclatura das versões:[.dd]: Nome do Revisor (e-mail)
REM Autor: Claudio Gomes Riella (
REM Versões:
REM 1.10.01 (1º/10/2009): Claudio Gomes Riella (
REM Parâmetros<-Argumentos: Main
REM FileHash(strFullPathName as String, strAlgorithm As String) <- Calc function FILEHASH(Cell; Algorithm)
REM TextHash(strText as String, strAlgorithm As String) <- Calc function TEXTHASH(Cell; Algorithm)
REM Resultados: return message digests
REM Requisitos mínimos: 3.1.0 ou 3.1.0 + Cryptographic Service 1.10.01
REM Licença: LGPL

Sub Main
Dim strFullPathName as String, sbNewLine as String
sbNewLine = Chr(13) + Chr(10)
strFullPathName = inputbox ("Insert the path of file")
msgbox "File is """ & strFullPathName & """" & sbNewLine & "FileHash: " & FileHash(strFullPathName, "MD5") & sbNewLine & "TextHash: " & TextHash(strFullPathName, "MD5")
End Sub

Function FileHash(strFullPathName as String, strAlgorithm As String)
Dim objDecrypt As Object
Set objDecrypt = CreateUnoService("org.openoffice.Cryptographic.CryptographicService")
FileHash = objDecrypt.GetFileHash(strFullPathName, strAlgorithm)
End Function

Function TextHash(strText as String, strAlgorithm As String)
Dim objDecrypt As Object
Set objDecrypt = CreateUnoService("org.openoffice.Cryptographic.CryptographicService")
TextHash = objDecrypt.GetTextHash(strText, strAlgorithm)
End Function

The functionality should be present.
To test, open a sheet and in a cell write : =TEXTHASH("test", "MD5")
If is working the hash :
should be calculated.


There are two main functionalities:



It calculate the hash using a text input.
Is possible to use different fileds concatenting them.
The macro requires two input:
  • the input text
  • the required algorithm from this list : MD2, MD5, SHA-1, SHA-256, SHA-384 and SHA-512
Valid Examples :
=TEXTHASH("Test string", "MD5")


It calculate the hash using a file. The input is the path of the file.
The macro requires two input:
  • the file path/name
  • the required algorithm from this list : MD2, MD5, SHA-1, SHA-256, SHA-384 and SHA-512
Valid Examples :
=FILEHASH("/testpath/file", "MD5")
=TEXTHASH(A1, "SHA-256") where A1 contains a valid path and file name


There are two problems I found so far.

  1. Sometime the result are 39 digits instead of 40.
  2. The hash calculation differs from the Linux version vs. the Windows version.

39 digit problem

The problem seems related to removing a hash number leading zero.

Different Hash calculation 

Didn't find yet an explanation. It could be related to a different Java version and thus different Java basic functions.

Saturday, February 7, 2015

littleBits - a comment

Recently I discovered the littleBits website.
I'm always looking to easy ways to  prototyping ideas. The "traditional way" has always a quite long preparation time, designing the circuit, building a prototype, verify if is working, etc.
So I took a look at this new system to do electronics.

Here what I think about this system. It is important to understand that I'm evaluating it from MY perspective and needs, not from a generic perspective.

Overall I found the idea nicer, but not 100% positive.

I received my first electronic kit  similar in “concept” when I was 10 years old, in the deep past of 1970s.
Of course it was very basic. No microcontrollers or computers at the time, but I did built a transistor radio and other things.
The idea to “simplify” the assembly of electronic circuits is not new.

The leap I noticed with littleBits was that they creates “virtual” blocks, that are much more than the single component.

A nice well designed training tool, until a certain point.
Let see more in details what I think.
  • Simple
    Sure it is simple to “assemble” circuit with this system.
    But it’s virtue is IMHO also it’s worse defect.  I found very probable that people who start to learn about electronics using this system, ends up with no clue about what he/she is doing.  Even a “simple” extension (to connect more modules) of this system has some electronic in it (analog buffer with an operational) and people who is supposed to learn “electronic” will never figure out that.Basically in order to simplify the assembly process, they created “meta-components” without any real technical description and a reason why they did it.In order to simplify the manual assembly, the cost is to don’t learn about the “real” components.For example, for each “module” there is a schematic but not a single word of explanation.How somebody is supposed to “learn” about electronic in this way ?
  • Limited
    The simplicity has also another cost : the complexity.Duh … yeah, if it is simple is not complex. But also it means that do even small applications with the “basic” components, is difficult and require a lot of space and modules.Another limit is the fact that each module has only 1 signal line. Love the idea, it simplify the connections, but for example:
    • Force to deal with analog voltages for everything
    • Imply to have a real “clean” power supply, the minimum “noise” on the power and your functionality is gone
    • Is more critical. It’s enough the “tolerance” of many components to introduce small variations among identical modules.
      It could mean to build something and if somebody try to replicate it, to have slightly  different results
    • Cannot be really fast.
      There is a lot of work behind the curtains in order to carry all the signals on a single line and this has a huge impact on the time.  Real time systems cannot be really developed with this system
  • Price
    Well, quite pricey !!
    To have enough modules to do some real work probably you have to invest AT LEAST 200-500$ and the material (blocks) are not usable in different projects (unless tear down what built).
    To have a full kit, i.e. everything available in enough quantity, is around 4000$ !!!
    For that amount you can set up much more than the “basics” with traditional electronic.
    I could build a more than decent personal lab with that amount, including quite a wide component selection and a lot of tools, from benches, furniture, power supplies (real ones, not USB limited  ), oscilloscopes, logic analyzer and so on. The basic entry point for this system is around 99$ …and really there is not much useful stuff that can be done.

So my impression is that is very nice introductory tool as long as :
  • You have a lot of money to “invest”
  • You are NOT interested to really learn electronic but just “build” something, possible guided by someone that tells you what modules to put together
  • You are not interested in replicate what you are doing (scale up an application)
  • You are not interested to deploy your buildings in the real world (mechanical issues – protection – etc.)
  • You have no constrains about space where to put the electronic
  • You don’t have to deal with “real time” or precision requirements

What is the “target” of this system then ?
IMHO for somebody who wants to build something more complicated than turn a lamp ON or OFF, but doesn't wants really to learn electronic and is willing to use whatever the “system” make available.
For electronic learning purposes I think that on the long run the risk to learn the wrong stuff is quite real.
Learning electronic imply to understand how each single component works, its limits and capabilities. Each littleBits module has more than one electronic component inside and understand how is really working imply to know a lot of electronic. So is a catch 22.
The littleBits modules hide totally each electronic component function.

Another potential user of this system is somebody who wants to see the feasibility of an idea and build a fast prototype.
An alternative way to the use of the breadboard.
IF the constraints I listed above are meet, it can be done. However the price is probably ten times more than the traditional way.
And the limits of the system are really too much  for professional use.

Just my 2 cents