• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

mikejsavage/lua-bcrypt: A bcrypt library for Lua

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

mikejsavage/lua-bcrypt

开源软件地址(OpenSource Url):

https://github.com/mikejsavage/lua-bcrypt

开源编程语言(OpenSource Language):

C 78.2%

开源软件介绍(OpenSource Introduction):

A Lua wrapper for OpenBSD's bcrypt.

Requirements

lua >= 5.1

Installation

$ luarocks install bcrypt

Usage

local bcrypt = require( "bcrypt" )

-- Bigger numbers here will make your digest exponentially harder to compute
local log_rounds = 9

local digest = bcrypt.digest( "password", log_rounds )
assert( bcrypt.verify( "password", digest ) )

Security concerns

Lua will keep plaintext passwords around in memory as part of its string interning mechanism. As far as I'm aware, there's nothing I can do about this.

Tuning

If you would like to automatically tune the number of rounds to your hardware, you can include a function like:

function bcrypt.tune( t )
	local SAMPLES = 10
	local rounds = 5

	while true do
		local total = 0

		for i = 1, SAMPLES do
			local start = os.clock()
			bcrypt.digest( "asdf", rounds )
			local delta = os.clock() - start

			total = total + delta
		end

		if ( total / SAMPLES ) * 1000 >= t then
			return rounds - 1
		end

		rounds = rounds + 1
	end
end

This function returns the largest load factor such that bcrypt.digest( str, work ) takes less than t milliseconds.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
mkottman/lqt: Lua bindings for Qt4 by Mauro Iazzi发布时间:2022-08-16
下一篇:
AndreiRudenko/linc_luajit: Haxe/hxcpp @:native bindings for LuaJIT.发布时间:2022-08-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap