Boris Nagaev · Home page | About | Contact | Github | Code | FBB files

Phpass password hashing for Lua

phpass (pronounced “pH pass”) is a portable public domain password hashing framework for use in PHP applications. phpass has been integrated into WordPress 2.5+, bbPress, Vanilla, PivotX 2.1.0+, Chyrp, Textpattern 4.4.0+, and concrete5 5.6.3+.

Lua module lua-phpass implements a subset of phpass (iterated MD5). It’s sufficient to create and check a password hash compatible with portable phpass hash, e.g. a password from wordpress database. Blowfish-based bcrypt and BSDI-style extended DES-based hashes are not supported.

This module is distributed under terms of the MIT License.

Read more

Lua MO files parser translates Lapis site

The parser for MO files was packaged for LuaRocks and uploaded to LuaRocks site as rock “mo”. It is available for installation under terms of MIT license.

$ luarocks install mo

MO file is binary format of GNU gettext used to store translations. It is created from PO file using tool msgfmt. It can be used to translate an application or a site from English to other language.

J.Jørgen von Bargen sent the code of parser to lua-l mailing list on Apr, 01, 2010. I have changed behavior of the function: now it returns translating function in case of success and function(x) return x end in case of errors. The code was covered with unit tests with coverage 100%. Unit tests are written using unit testing framework Busted.

Read more

Introducing lua-rote, Lua binding to ROTE, Terminal Emulation library

ROTE is a simple C library for VT102 terminal emulation. It allows the programmer to set up virtual ‘screens’ and send them data. The virtual screens will emulate the behavior of a VT102 terminal, interpreting escape sequences, control characters and such. The library supports ncurses as well so that you may render the virtual screen to the real screen when you need to.

There are several programs that do terminal emulation, such as xterm, rxvt, screen and even the Linux console driver itself. However, it is not easy to isolate their terminal emulation logic and put it in a module that can be easily reused in other programs. That’s where the ROTE library comes in.

The goal of the lua-rote library is to provide terminal emulation support for Lua applications, making it possible to write programs that display terminals in embedded windows within them, or even monitor the display produced by other programs. The lua-rote library depend only on Lua, ROTE itself, ncurses and luaposix.

The ROTE library is able to render the virtual screens to the physical screen (actually any ncurses window) and can also translate ncurses key codes to the escape sequences the Linux console would have produced (and feed them into the terminal). Using ncurses is not mandatory however, and ROTE will work fine without it, but in that case the application must take care of drawing the terminal to the screen in whichever way it sees fit.

ROTE also encapsulates the functionality needed to execute a child process using the virtual screen as the controlling terminal. It will handle the creation of the pseudo-terminal and the child process. All the application has to do is tell it the command to run in the terminal and call an update function at regular intervals to allow the terminal to update itself.

ROTE is extremely useful to programmatically interact with curses applications (e.g., for unit testing).

Read more

Bitcoin deposits for deals (Howto)

Bitcoin is a very convenient and reliable as a storage of money. But how can you carry out deals with it? Traditional methods introduce a trusted third party. Bitcoin turned out to be powerful enough to carry out deals safely without involment of third parties. Below is a detailed instruction of how to carry out a deal with anybody you do not trust without involment of third parties.

esrow

Let us review existing methods at first.

Using a transaction with traditional money

When using a transaction with traditional money, you rely on existing laws protecting both parties from each other. This requires the inclusion of a third party. Furthermore, there is no anonymity and exchange fees are added.

Carrying out transactions using an escrow account

An escrow is a third party trusted by both parties to the transaction. the buyer gives money to an escrow, and the seller gives the goods to the escrow. Then the escrow gives money to the seller and the goods to buyer. This method has a drawback. The escrow has to accumulate a good reputation. The better the reputation, the more deals are consequently mediated by the escrow. Escrow is a system with positive feedback, therefore the overall number of escrows decreases, which results in centralization. Centralization is not ideal, because it results in a monopoly and creates less competition.

Bitcoin deals without third parties

Third parties are not needed for a bitcoin deal. A buyer, a seller and the bitcoin itself are sufficient for a secure deal. Banks, money exchanges, lawyers, and escrows are parasitizing on deals. The protocol of bitcoin already has all that is needed to carry out a secure deal.

The algorithm is very simple: both parties deposit some money. If the deal succeeds, the money is returned, otherwise it is lost.

Read more