[Solved] Compute MD5 checksum of a string with AOO Basic
[Solved] Compute MD5 checksum of a string with AOO Basic
Hallo! I'm trying to create a code, that translates wiki source code to OpenOffice writer (see https://de.wikibooks.org/wiki/Benutzer: ... amm_selber). For Wikimedia sources i need the md5 checksum. I already found out that there is a MD5Thumbprint in the Documentation, so there must be a way to generate the md5 checksum for any string. Is there anybody that can help me on this? To be more exact: I need a command or a combination like stringMD5=s.md5(), where s will be a string (for example something like "Douglas C-47 Skytrain.jpg") and stringMD5 should be a string or something that I can make to a string (in this example the outcome in the end should be the string "40decfb5f1be8bca1e56c8a853027941"). thanx in advance! Georg
Last edited by Hagar Delest on Mon Jul 25, 2016 9:20 pm, edited 1 time in total.
Reason: tagged [Solved].
Reason: tagged [Solved].
OpenOffice3.1 on UBUNTU 12.04
Re: how do I compute the MD5 checksum of a string?
Your Ubuntu comes with a program called "md5sum".
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: how do I compute the MD5 checksum of a string?
And for instructions type "man md5sum" (no quotes) in a terminal.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
Re: how do I compute the MD5 checksum of a string?
Thanx for the quick answer. Sorry, I forgot to write here the basic info: what I m making is an OpenOfficeWriter StarBasic-Macro Programm and no terminal. So what I need is a Macro that generates the MD5 checksum. There is a MD5Thumbprint (https://www.openoffice.org/api/docs/com ... Thumbprint) in the Documentation for OpenOffice, so I suppose you can compute the MD5 in a Open Office macro using some kind of macro code. This is what I'm looking for. I suppose i have to use the XCertificate Interface (https://www.openoffice.org/api/docs/com ... icate.html )in the security module(https://www.openoffice.org/api/docs/com ... le-ix.html), but i don't know how the macro code is looking. So, once more I need a Open Office command or a code like stringMD5=s.md5(), where s will be a string (for example something like "Douglas C-47 Skytrain.jpg") and stringMD5 should be a string or something that I can make to a string (in this example the outcome in the end should be the string "40decfb5f1be8bca1e56c8a853027941", which is the MD5 for the String "Douglas C-47 Skytrain.jpg"). Another possibility is of course to open a terminal through the macro and create there the MD5 or to open a site (like http://www.miraclesalad.com/webtools/md5.php) through a macro and find a way to get the MD5 from command line or the site, but I still have the impression, that there is a simpler way to compute the MD5 with a macro and within the macro. If somebody has a tip, I will be of course very glad! 

OpenOffice3.1 on UBUNTU 12.04
Re: how do I compute the MD5 checksum of a string?
Python can be used as macro language. The default office install includes a Python runtime.
http://stackoverflow.com/questions/5297 ... ng#5297495
http://stackoverflow.com/questions/5297 ... ng#5297495
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: how do I compute the MD5 checksum of a string?
Thanks once more. This solution means that I also have to learn how to create a Python macro and then how to use it in the starbasic macro. I had hoped for a more direct solution (and there should be one), but if nothing else comes up, I will use this idea! I wil ask then also in the stackoverflow Forum. Schöne Ferien (in case we dont contact again before winter)!
OpenOffice3.1 on UBUNTU 12.04
Re: how do I compute the MD5 checksum of a string?
Basic is dead, clumsy, difficult. You dont find recent literature on Basic.
Pyton is a professional and modern programming lanuguage (yes, it is easier than Basic).
Stuff like this should be wrapped in a spreadsheet add-in (a package that adds functions to Calc's function wizard). Nevertheless it can be done with pure scripting. The attached spreadsheet document calls a Basic function PYFUNCTION which itself calls a specified Python function in Python module SheetFunctions.py with up to 6 positional arguments.
menu:Tools>Macros>Organize>Basic... [Organizer...], Ctrl+Drag&Drop copies a module from one library to another library.
From your own Basic code you can call my Basic function PYFUNCTION which will call the right Python code.
PYFUNCTION takes the name of a Python function and up to 6 discrete arguments to be passed to this function (no array arguments yet).
--------- OFF TOPIC ---------
If the code was wrapped in a Calc add-in, the function call would require the installation of an extension package and then:
The function would appear as a normal spreadsheet function MD5SUM among the other spreadsheet functions.
Pyton is a professional and modern programming lanuguage (yes, it is easier than Basic).
Stuff like this should be wrapped in a spreadsheet add-in (a package that adds functions to Calc's function wizard). Nevertheless it can be done with pure scripting. The attached spreadsheet document calls a Basic function PYFUNCTION which itself calls a specified Python function in Python module SheetFunctions.py with up to 6 positional arguments.
Move the Basic module of the attached spreadsheet to your global Basic container.Save the Python code (embedded Writer object) unmodified as plain text file under
<user_profile>/Scripts/python/SheetFunctions.py
Right-click>Save Copy As...
Automatic file name extension = OFF (or rename SheetFunctions.txt to SheetFunctions.py later)
File Type: Text(*.txt)
Browse to the the Scripts folder and create a subdirectory “python” if necessary and save as “SheetFunctions.py”
Hit Ctrl+Shift+F9 to recalculate the above formulas
Don't forget to turn on the automatic file name extension when you save the next document.
menu:Tools>Macros>Organize>Basic... [Organizer...], Ctrl+Drag&Drop copies a module from one library to another library.
From your own Basic code you can call my Basic function PYFUNCTION which will call the right Python code.
PYFUNCTION takes the name of a Python function and up to 6 discrete arguments to be passed to this function (no array arguments yet).
Code: Select all
REM if you put my Basic to a lib other than "Standard":
GlobalScope.BasicLibraries.loadLibrary("LibraryName")
REM let's use a Writer selection of text:
s = ThisComponent.CurrentSelection(0).getString()
md5hash = PYFUNCTION("md5sum", s)
If the code was wrapped in a Calc add-in, the function call would require the installation of an extension package and then:
Code: Select all
REM pass a text selection in Writer to a spreadsheet function:
srv = createUnoService("com.sun.star.sheet.FunctionAccess")
s = ThisComponent.CurrentSelection(0).getString()
md5hash = srv.callFunction("org.villeroy.PyFunctions.getMD5SUM", s)
- Attachments
-
- PyFunctions.ods
- Calling Python through Basic
- (27.21 KiB) Downloaded 321 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Compute the MD5 checksum of a string with AOO Basic
thanks a lot for taking all this effort. For the time being i used http://extensions.services.openoffice.o ... nofficeorg, which was enough for me.
OpenOffice3.1 on UBUNTU 12.04