---
title: "Java 实现RFC2898"
author: "ping2010"
date: "2014-08-07T16:49:38Z"
tags: []
categories: ["编程语言"]
slug: "java-rfc2898"
draft: false
lastmod: "2014-08-07T16:49:38Z"
id: 2101425
url: "https://ping2010.iteye.com/blog/2101425"
---

```
package crypto.test;

public class CryptoToolsTest {

	public static void main(String[] args) {
		//hash password
		String salt = CryptoTools.generateSalt();
		String password= "123456" ;
		String hashPassword = CryptoTools.hash(password+salt);
		System.out.println("hashPassword:"+hashPassword);
		System.out.println("salt:"+salt);
		System.out.println("password:"+password);
		//verify
		boolean result = CryptoTools.verify(hashPassword, password+salt);
		System.out.println("Verify:"+result);
	}
}
```