资源简介
代码片段和文件信息
// Copyright (c) 2006 Damien Miller
//
// Permission to use copy modify and distribute this software for any
// purpose with or without fee is hereby granted provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED “AS IS“ AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL DIRECT INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE DATA OR PROFITS WHETHER IN AN
// ACTION OF CONTRACT NEGLIGENCE OR OTHER TORTIOUS ACTION ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package entity;
import java.io.UnsupportedEncodingException;
import java.security.SecureRandom;
/**
* BCrypt implements OpenBSD-style Blowfish password hashing using
* the scheme described in “A Future-Adaptable Password Scheme“ by
* Niels Provos and David Mazieres.
*
* This password hashing system tries to thwart off-line password
* cracking using a computationally-intensive hashing algorithm
* based on Bruce Schneier‘s Blowfish cipher. The work factor of
* the algorithm is parameterised so it can be increased as
* computers get faster.
*
* Usage is really simple. To hash a password for the first time
* call the hashpw method with a random salt like this:
*
*
* String pw_hash = BCrypt.hashpw(plain_password BCrypt.gensalt());
*
*
* To check whether a plaintext password matches one that has been
* hashed previously use the checkpw method:
*
*
* if (BCrypt.checkpw(candidate_password stored_hash))
* System.out.println(“It matches“);
* else
* System.out.println(“It does not match“);
*
*
* The gensalt() method takes an optional parameter (log_rounds)
* that determines the computational complexity of the hashing:
*
*
* String strong_salt = BCrypt.gensalt(10)
* String stronger_salt = BCrypt.gensalt(12)
*
*
* The amount of work increases exponentially (2**log_rounds) so
* each increment is twice as much work. The default log_rounds is
* 10 and the valid range is 4 to 30.
*
* @version 0.2
*/
public class BCrypt {
// BCrypt parameters
private static final int GENSALT_DEFAULT_LOG2_ROUNDS = 10;
private static final int BCRYPT_SALT_LEN = 16;
// Blowfish parameters
private static final int BLOWFISH_NUM_ROUNDS = 16;
// Initial contents of key schedule
private static final int P_orig[] = {
0x243f6a88 0x85a308d3 0x13198a2e 0x03707344
0xa4093822 0x299f31d0 0x082efa98 0xec4e6c89
0x452821e6 0x38d01377 0xbe5466cf 0x34e90c6c
0xc0ac29b7 0xc97c50dd 0x3f84d5b5 0xb5470917
0x9216
相关资源
- pentaho kettle solutions电子书及完整源码
- 几十个微信H5小游戏完整源码
- 深入浅出Spring Boot 2.x 源码,完整源码
- .net经典会员管理项目完整源码(包含
- 微信小程序包你说红包完整源码带后
- .net自动排课系统完整源码(适合智慧
- net自动排课系统完整源码(适合智慧
- 最新SSC喜虎完整源码.zip
- .net RBAC通用权限设计与实现完整源码
- 控制系统计算机辅助设计_薛定宇_第三
- 《Introduction to 3D Game Programming with Di
- 个人博客完整源码
- ssh作业管理系统完整源码
- 灰鸽子1.2完整源码+完整控件
- win32的88个项目完整源码
- unity3D宝石三消手机游戏完整源码
- 2018精仿包图网素材图片整站完整源码
- OpenGL 4.0 Shading Language Cookbook及完整源
- unity3D孤胆枪手手游完整源码
- 3D太空射击游戏unity3d完整源码
- 基于FFmpegQt的视频播放器完整源码.r
- SSH网上商城项目实战完整源码
- JM沟通社交交友app完整源码.zip
- 可可通直拨系统完整源码
- 仿通达OA完整源码
- 手机安全卫士完整源码
- SignalR完整源码
- OpenGL超级宝典完整源码(第五版)
- .net商品销售管理系统完整源码(进销
- .net经典会员管理项目完整源码(包含
评论
共有 条评论