bzr branch
http://gegoxaren.bato24.eu/bzr/magstudentportal/trunk
15.1.7
by Gustav Hartvigsson
* added a few things that will help with development |
1 |
package common; |
2 |
||
3 |
public class |
|
4 |
Utils { |
|
5 |
private Utils () {}; |
|
6 |
|
|
7 |
/** |
|
8 |
* A hash function that salts the password
|
|
9 |
* in a way that is pseudo dynamic.
|
|
10 |
*
|
|
11 |
* @param t the text to salt
|
|
12 |
* @param s the salt
|
|
13 |
* @return
|
|
14 |
*/
|
|
15 |
static public String |
|
16 |
real_hash_func (String t, String s) { |
|
17 |
int a = t.getBytes()[0]; |
|
18 |
int b = t.getBytes()[a%t.length()]; |
|
19 |
|
|
15.2.6
by Gustav Hartvigsson
* Started work on the design |
20 |
StringBuilder sb = new StringBuilder (); |
21 |
sb.append (t).insert (b, s); |
|
22 |
|
|
23 |
return sb.toString(); |
|
15.1.7
by Gustav Hartvigsson
* added a few things that will help with development |
24 |
} |
25 |
|
|
26 |
/** |
|
27 |
* Hash a text with a salt.
|
|
28 |
*
|
|
29 |
* @param t
|
|
30 |
* @return
|
|
31 |
*/
|
|
32 |
static public String |
|
33 |
hash_func (String t) { |
|
34 |
return real_hash_func(t, common.Config.PW_SALT); |
|
35 |
} |
|
36 |
|
|
37 |
|
|
38 |
}
|