Cryptographic Hash Functions UNO Component for OpenOffice.org

×

Message d'avertissement

This extension was not updated recently. It might not work with latest versions of OpenOffice.

Onglets principaux

Maintainer:
Claudio Gomes Riella
Note:
3.666665

Average: 3.7 (3 votes)

Application:
OpenOffice.org
Étiquettes:
hashes, message digests, Cryptographic, extension
Source code:
https://sourceforge.net/projects/cryptographic/files/
Date de publication:
Vendredi, 2 Octobre, 2009 - 08:48
Statistiques
Week: Non suivi - Mois: Non suivi - Année: Non suivi - Timeline
Download extension
System Independent version - All releases
Compatible with OpenOffice 4: Inconnu
User feedback:
Compatible with OpenOffice 4.x?

The Cryptographic Hash Functions UNO Component for OpenOffice.org ("org.openoffice.Cryptographic.CryptographicService") computes hashes (message digests) of text and files using following hashing algorithms: MD2, MD5, SHA-1, SHA-256, SHA-384 and SHA-512.
Source Code and Examples (FILEHASH and TEXTHASH functions.ods, Find Duplicate Files.odb) in https://sourceforge.net/projects/cryptographic/files/

Cryptographic Hash Functions UNO Component for OpenOffice.org

Version Operating system Compatibility Release date
1.10.01 System Independent 3.1, 3.2, 3.3, 3.4 02/10/2009 - 21:44 Plus d'information Download

Commentaires

TQ for this excellent macro!

However, there seems to be a bug: when the hash starts with a ZERO, the 0 does not seem to be returned.

For example:
0755f263f216ffee5fd3f50c2eb56bdf4f7b3829 becomes
755f263f216ffee5fd3f50c2eb56bdf4f7b3829

Yesterday I tried it and was still absolutely compatible with LibreOffice 7.0.1.2. (At least on Linux/Ubuntu 20.04).

But as other users mentioned we need taking to account that the solution will cut/drop all leading zeros of the generated hashes. This is usually not a big problem if you care with it (as you can cut the leading zeros in any other hash list also therefore the result will be the same) just need to know!

(Of course you need to use the required macro, what call the plugin and working JRE (Java runtime environment) behind your LibreOffice.)

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: a.mm[.dd]: Nome do Revisor (e-mail)
REM Autor: Claudio Gomes Riella (cgriella@ufrgs.br)
REM Versões:
REM 1.10.01 (1º/10/2009): Claudio Gomes Riella (cgriella@ufrgs.br)
REM Parâmetros REM FileHash(strFullPathName as String, strAlgorithm As String) REM TextHash(strText as String, strAlgorithm As String) REM Resultados: return message digests
REM Requisitos mínimos: BrOffice.org 3.1.0 ou OpenOffice.org 3.1.0 + Cryptographic Service 1.10.01
REM Licença: LGPL

REM comments on the refinements:
REM You can comment out the Beeps are sounded to note that a Hashes length was fixed.
REM Useful, or not, there are now two ways to call the process that gives the Messagebox query and results.
REM If there is no change in the calling function's equation then it is skipped. 'Rnd' may be helpful to be sure it's usually triggered.

Sub Main
Ask4File2Hash("")
End Sub

Function Ask4File2Hash( strX as String )
Dim strFullPathName as String, sbNewLine as String
sbNewLine = Chr(13) + Chr(10)
strFullPathName = inputbox ("Insert the path of file")
msgbox "The 'full filename' you gave is """ & strFullPathName & """" & sbNewLine & "The MD5 FileHash: " & FileHash(strFullPathName, "MD5") & sbNewLine & "The MD5 'TextHash' for the string you gave for locating the file is: " & TextHash(strFullPathName, "MD5")
End Function

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

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

Function ChksumLenFix( strChksm as STRING, strAlgorithm as String )
If ( strAlgorithm = "MD2" Or strAlgorithm = "MD5" ) Then ChkLn = 32
If strAlgorithm = "SHA-1" Then ChkLn = 40
If strAlgorithm = "SHA-256" Then ChkLn = 64
If strAlgorithm = "SHA-384" Then ChkLn = 96
If strAlgorithm = "SHA-512" Then ChkLn = 128
If ChkLn > Len( strChksm ) Then
Beep
ChksumlenFix = String( ChkLn - Len( strChksm ), "0" ) + strChkSm
Else
ChksumlenFix = strChkSm
End If
END Function

The link contains a sample ( MD5_BASIC_SAMPLE.ods ) with macros developed in LibreOffice, which calculates the MD5 hash from a sample text. The macro is it based on the Robert Hubley development. I hope they can be helpful.

http://sites.google.com/site/elecyelec/Trabajos-y-Premios

Regards.

This fantastic extension has been with me since I ofund it in 2010 and is still working brilliantly. The 39 character bug I havce luckily not experienced, but the other comments seem more like people not comfortable with macro programming. I have used it in OOCalc on several Ubuntu editions as well as Windows XP, Vista, W7 and W8 - today I run it on LibreOffice 4.0.3.3 in Win8 without any issues.

To Mr Claudio Gomes Riella; Thank you and I do hope you keep it alive in case it ever will need an update in later OO/LO editions.

Hello,

Some results are given with 39 characters instead of 40.

Exemple, when I hash :
noe.dekkerf29ru6ap
it gives me:
accf66bbda7debaf7813a8dd9827c1ca29adb3e

Misses one character. I discovered that the one missing is a 0 at the beginning, the correct hash is:
0accf66bbda7debaf7813a8dd9827c1ca29adb3e

Can somebody find the origin of this bug ? I'm not a programmer.
Thanks.

I found I installed the uno. Then from the example sheet from sourceforge there is a basic macro adding the functions.
When you create a new sheet, you need to add this basic macro (copy/paste) to the new sheet and the functions will work.

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: a.mm[.dd]: Nome do Revisor (e-mail)
REM Autor: Claudio Gomes Riella (cgriella@ufrgs.br)
REM Versões:
REM 1.10.01 (1º/10/2009): Claudio Gomes Riella (cgriella@ufrgs.br)
REM Parâmetros REM FileHash(strFullPathName as String, strAlgorithm As String) REM TextHash(strText as String, strAlgorithm As String) REM Resultados: return message digests
REM Requisitos mínimos: BrOffice.org 3.1.0 ou OpenOffice.org 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

This did it for me. Thank you :)

LibreOffice 3.5.4.2
Build ID: 350m1(Build:2)

I have installed the extension and your example spreadsheet works great.

However, the formula typed in a new spreadsheet does not work. What am I missing?

Your help would be greatly appreciated!

Ok, may be I skrewed something up, but this extension does not do anything for me. Also the example ODS sheet does not work. I tested it on three different machines (Fedora, WinXP, OS X) all running OOo 3.1.1 and I only get "#NAME?" errors. Any ideas?

It uses macros. Did you enable macro security to allow it?
Did you install the JRE?

With the extension installed, in Calc 3.4, Win 7

typing
=texthash('fff','md5')

results in
#NAME?