Documentation[voir] [modifier] [historique] [purger]

Utilisation

modifier

Ce module est utilisé par le modèle {{Hachage}} et sa documentation.

Code Lua

modifier

Dans du code Lua, ne pas utiliser ce module, qui est superflu ; utiliser directement mw.hash.hashValue().

Exemples :

mw.hash.hashValue( 'md5', 'texte à hacher' )

mw.hash.hashValue( 'md5', 'texte à hacher' ):sub( 1, 24 )
local p = {}

function p.main( frame )
    local args = frame.args
    local result = mw.hash.hashValue( args.algo, args.value )
    if args.rognage and args.rognage ~= '' then
        result = result:sub( 1, tonumber( args.rognage ) )
    end
    return result
end

function p.algosList()
    local algos = mw.hash.listAlgorithms()
    local lines = {}
    for i = 1, #algos do
        table.insert( lines, '* ' .. algos[ i ] )
    end
    return table.concat( lines, '\n' )
end

return p