本文整理汇总了Java中org.openyu.commons.security.SecurityHelper.md方法的典型用法代码示例。如果您正苦于以下问题:Java SecurityHelper.md方法的具体用法?Java SecurityHelper.md怎么用?Java SecurityHelper.md使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openyu.commons.security.SecurityHelper
的用法示例。
在下文中一共展示了SecurityHelper.md方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: md
import org.openyu.commons.security.SecurityHelper; //导入方法依赖的package包/类
@Test
// 1000000 times: 3981 mills.
// 1000000 times: 3787 mills.
// 1000000 times: 3979 mills.
public void md() {
String value = "中文測試abcdef";
String algorithm = "MD5";
byte[] result = null;
int count = 1000000;
long beg = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
result = SecurityHelper.md(value, algorithm);
}
long end = System.currentTimeMillis();
System.out.println(count + " times: " + (end - beg) + " mills. ");
SystemHelper.println(result);// 51, -46, 64, -103, -104, -110, -80, -9,
// 12, -98, 17, 114, -4, -93, 90, 27
assertEquals(16, result.length);
}
示例2: secureRandomInt
import org.openyu.commons.security.SecurityHelper; //导入方法依赖的package包/类
@Test
// 1000000 times: 258 mills.
// 1000000 times: 262 mills.
// 1000000 times: 262 mills.
//
// verified
public void secureRandomInt() {
int result = 0;
int count = 1000000;
long beg = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
result = NumberHelper.secureRandomInt(0, 100);
}
long end = System.currentTimeMillis();
System.out.println(count + " times: " + (end - beg) + " mills. ");
System.out.println(result);
assertTrue(result >= 0);
//
result = NumberHelper.secureRandomInt(100);
System.out.println(result);
//
result = NumberHelper.secureRandomInt();
System.out.println(result);// -1667663275,1879823349
//
byte[] bytes = SecurityHelper.md("" + result);
String encodeByHex = EncodingHelper.encodeHex(bytes);// e19db4f307a5ae5fb82260e3ff043e0e
System.out.println("encodeByHex: " + encodeByHex);
//
byte[] randomBytes = new byte[32];
SecureRandom secureRandom = new SecureRandom();
secureRandom.nextBytes(randomBytes);
System.out.println(secureRandom.nextInt());
System.out.println(secureRandom.nextInt());
}
示例3: ACCOUNT_AUTHORIZE_REQUEST
import org.openyu.commons.security.SecurityHelper; //导入方法依赖的package包/类
@Test
public void ACCOUNT_AUTHORIZE_REQUEST() {
final String ACCOUNT_ID = "TEST_ACCOUNT_1";
final String ALGORITHM = "MD5";
// 048f4d8d4bc291ba442363d65d51ad29
byte[] buff = SecurityHelper.md("1111", ALGORITHM);
final String PASSWORD = EncodingHelper.encodeHex(buff);
// System.out.println(PASSWORD);
//
Message message = messageService.createClient(ACCOUNT_ID,
CoreMessageType.ACCOUNT_AUTHORIZE_REQUEST);
message.addString(ACCOUNT_ID);
message.addString(PASSWORD);
accountSocklet.service(message);
}