forked from Blankj/AndroidUtilCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncryptUtilsTest.java
More file actions
78 lines (59 loc) · 2.1 KB
/
EncryptUtilsTest.java
File metadata and controls
78 lines (59 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.blankj.utilcode.utils;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2016/8/6
* desc : EncryptUtils单元测试
* </pre>
*/
public class EncryptUtilsTest {
@Before
public void setUp() throws Exception {
}
@Test
public void testGetMD5() throws Exception {
assertEquals(EncryptUtils.getMD5("blankj"), "AAC25CD336E01C8655F4EC7875445A60");
}
@Test
public void testGetMD51() throws Exception {
assertEquals(EncryptUtils.getMD5("blank", "j"), "AAC25CD336E01C8655F4EC7875445A60");
}
@Test
public void testGetMD52() throws Exception {
assertEquals(EncryptUtils.getMD5("blankj".getBytes()), "AAC25CD336E01C8655F4EC7875445A60");
}
@Test
public void testGetMD53() throws Exception {
assertEquals(EncryptUtils.getMD5("blank".getBytes(), "j".getBytes()), "AAC25CD336E01C8655F4EC7875445A60");
}
@Test
public void testEncryptMD5() throws Exception {
assertEquals(EncryptUtils.bytes2Hex(EncryptUtils.encryptMD5("blankj".getBytes())), "AAC25CD336E01C8655F4EC7875445A60");
}
@Test
public void testGetMD5File() throws Exception {
}
@Test
public void testGetMD5File1() throws Exception {
}
@Test
public void testGetSHA() throws Exception {
assertEquals(EncryptUtils.getSHA("blankj"), "C606ACCB1FEB669E19D080ADDDDBB8E6CDA5F43C");
}
@Test
public void testGetSHA1() throws Exception {
assertEquals(EncryptUtils.getSHA("blankj".getBytes()), "C606ACCB1FEB669E19D080ADDDDBB8E6CDA5F43C");
}
@Test
public void testEncryptSHA() throws Exception {
assertEquals(EncryptUtils.bytes2Hex(EncryptUtils.encryptSHA("blankj".getBytes())), "C606ACCB1FEB669E19D080ADDDDBB8E6CDA5F43C");
}
@Test
public void testBytes2Hex() throws Exception {
assertEquals(EncryptUtils.bytes2Hex(new byte[]{(byte) 0xff, (byte) 0x11}), "FF11");
}
}