crypt

What is the output length of PHP crypt()? [closed]

北战南征 提交于 2019-12-10 01:50:02
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . what's the output length of PHP crypt() ? md5() output is 128 bits and produce a string with 32 chars, so in data base you put that in a char(32) column, what about the crypt() ? 回答1: Note: It is totally limited

strcmp vs. == vs. === in PHP for checking hash equality

做~自己de王妃 提交于 2019-12-09 14:40:34
问题 I'm using crypt() to hash passwords in PHP, and am trying to work out the safest way of testing equality of the resulting hash when performing password checks. There are three options that I can see: Option 1 - Double Equals function checkPassword($hash, $password) { return crypt($password, $hash) == $hash; } Option 2 - Triple Equals function checkPassword($hash, $password) { return crypt($password, $hash) === $hash; } Option 3 - strcmp() function checkPassword($hash, $password) { return

为skynet的crypt库扩展一些加密(摘要)算法支持

十年热恋 提交于 2019-12-09 13:26:04
改造起因 在 上篇文章 , 我描述了为 skynet 添加稳定的 websocket 支持的起始并阐述了这么做的原因. 这几天在测试的时候发现, 当使用 skynet 内置的httpc库的时候会遇见 crypt 缺少一些我需要用到的算法(例如: crc 、 sha256 、 hmac_sha256 等等). 这里完全可以假设开发者在框架选型的时候没发现这个问题, 那可能会到开发中期需要第三方平台接入或扩展不同架构的时候才可能会发现了. 显然这将会在无形之中就会给一个项目引入不可预料的稳定性因素. 为了尽可能的避免这个因素, 扩展一些常见的加密(摘要)算法支持是必不可少的. 首选方案肯定使用已经成熟的库. 但是很可惜, lua5.3没有较为可靠并且现成的实现库可以 fork 后直接使用. 而且可以用来参考的库仅有: luajit 利用 ffi 实现的库、 OpenSSL 的实现. 然而这些无法直接或间接移植到lua 5.3. 这是目前遇到的最坏的情况! 最终, 我们只能用Lua的C API来粘合C语言的Crypt实现来完成Lua版本的Crypt扩展库改造工作. 改造开始 我在网上寻找一段时间后发现一个比较不错的 Lua sha实现 . 这份代码包含 md5 、 sha128 、 sha384 、 sha512 的C实现, 其用大量的宏来完成Lua注入动作.

PHP crypt() returning wrong answer

不打扰是莪最后的温柔 提交于 2019-12-08 16:23:12
问题 I think i'm losing my marbles here... I've got a problem on my web site where randomly it stops accepting logins. I've now been able to trace it to crypt() behaving very strangely. In my database, i've got the crypted version of the users password - so let's say Og12345678. When the user logs in, they enter their password, I read the salt out of the db and then crypt what they entered and compare - usually this works very well. So i'm doing crypt($enteredPassword, $saltFromDb) - in this case,

Why does my crypt package give me invalid magic prefix error?

老子叫甜甜 提交于 2019-12-08 15:36:26
问题 I have the following code: import "github.com/kless/osutil/user/crypt/sha512_crypt" c := sha512_crypt.New() hash, err := c.Generate([]byte("enter-new-password"), []byte("$2a$09$f5561d2634fb28a969f2dO8QeQ70f4bjCnF/.GvPpjj.8jgmtzZP2")) if err != nil { panic(err) } And it produced the following error http: panic serving 192.168.0.16:56730: invalid magic prefix Why does this happen and how do I resolve it? 回答1: Why does this happen and how do I resolve it? You have an invalid magic prefix. github

What is Go's equivalent to Python's crypt.crypt?

随声附和 提交于 2019-12-07 05:20:36
问题 I am currently playing around with an example from the book Violent Python. You can see my implementation here I am now trying to implement the same script in Go to compare performance, note I am completely new to Go. Opening the file and iterating over the lines is fine, however I cannot figure out how to use the "crypto" library to hash the string in the same way as Python's crypt.crypt(str_to_hash, salt). I thought it maybe something like import "crypto/des" des.NewCipher([]byte("abcdefgh"

PHP storing password with blowfish & salt & pepper

£可爱£侵袭症+ 提交于 2019-12-06 14:42:39
问题 I want to store secure user passwords in a MySQL database with PHP. How can I make it better? My Class: private static $algo = '$2a'; private static $cost = '$10'; private static $pepper = 'eMI8MHpEByw/M4c9o7sN3d'; public static function generateSalt($length) { $randomBinaryString = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); $randomEncodedString = str_replace('+', '.', base64_encode($randomBinaryString)); return substr($randomEncodedString, 0, $length); } public static function

PHP crypt(pass, salt) alternative in Java - Blowfish algorithm

*爱你&永不变心* 提交于 2019-12-06 08:59:19
问题 I'm using on php server function crypt like this: $hash = crypt($password, '$2y$10$' . $salt); It makes hash of password by Blowfish method. I'm looking for java equivalent for crypt password. I found this code, but I don't know where add $salt. More above: String key = "abcd"; SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "Blowfish"); Cipher cipher = Cipher.getInstance("Blowfish"); cipher.init(cipher.ENCRYPT_MODE, keySpec); return DatatypeConverter.printBase64Binary(cipher

How do I replace the cakephp password hashing algorithm?

≯℡__Kan透↙ 提交于 2019-12-06 02:06:13
问题 I have an existing database I'm trying to put a cake app on top of. The old app used crypt() in Perl to hash the passwords. I need to do the same in the PHP app. Where is the correct place to make that change in a standard cakephp app? And what would such a change look like? 回答1: I got it working... here is my AppController: class AppController extends Controller { var $components = array('Auth'); function beforeFilter() { // this is part of cake that serves up static pages, it should be

What is Go's equivalent to Python's crypt.crypt?

一世执手 提交于 2019-12-05 10:34:13
I am currently playing around with an example from the book Violent Python. You can see my implementation here I am now trying to implement the same script in Go to compare performance, note I am completely new to Go. Opening the file and iterating over the lines is fine, however I cannot figure out how to use the "crypto" library to hash the string in the same way as Python's crypt.crypt(str_to_hash, salt). I thought it maybe something like import "crypto/des" des.NewCipher([]byte("abcdefgh")) However, no cigar. Any help would be much appreciated as it'd be really interesting to compare Go's