14
14
*
15
15
* @author Aaron Hansen
16
16
*/
17
- public class DSPasswordAes extends DSValue implements DSIPassword , DSIStorable {
17
+ public class DSPasswordAes256 extends DSValue implements DSIPassword , DSIStorable {
18
18
19
19
// Constants
20
20
// ---------
21
21
22
22
private static Cipher cipher ;
23
23
private static Key key ;
24
- public static final DSPasswordAes NULL = new DSPasswordAes (DSString .NULL );
24
+ public static final DSPasswordAes256 NULL = new DSPasswordAes256 (DSString .NULL );
25
25
26
26
// Fields
27
27
// ------
@@ -31,11 +31,11 @@ public class DSPasswordAes extends DSValue implements DSIPassword, DSIStorable {
31
31
// Constructors
32
32
// ------------
33
33
34
- private DSPasswordAes (DSString encrypted ) {
34
+ private DSPasswordAes256 (DSString encrypted ) {
35
35
this .value = encrypted ;
36
36
}
37
37
38
- private DSPasswordAes (String encrypted ) {
38
+ private DSPasswordAes256 (String encrypted ) {
39
39
this (DSString .valueOf (encrypted ));
40
40
}
41
41
@@ -86,7 +86,7 @@ public static String encode(String arg) {
86
86
87
87
@ Override
88
88
public boolean equals (Object obj ) {
89
- if (obj instanceof DSPasswordAes ) {
89
+ if (obj instanceof DSPasswordAes256 ) {
90
90
return value .equals (obj .toString ());
91
91
}
92
92
return false ;
@@ -148,11 +148,11 @@ public DSString store() {
148
148
}
149
149
150
150
@ Override
151
- public DSPasswordAes restore (DSElement element ) {
151
+ public DSPasswordAes256 restore (DSElement element ) {
152
152
if (element .isNull ()) {
153
153
return NULL ;
154
154
}
155
- return new DSPasswordAes (element .toString ());
155
+ return new DSPasswordAes256 (element .toString ());
156
156
}
157
157
158
158
/**
@@ -178,7 +178,7 @@ public String toString() {
178
178
* @return Returns the NULL instance if the arg is null, isNull() or the empty string.
179
179
*/
180
180
@ Override
181
- public DSPasswordAes valueOf (DSElement arg ) {
181
+ public DSPasswordAes256 valueOf (DSElement arg ) {
182
182
if ((arg == null ) || arg .isNull ()) {
183
183
return NULL ;
184
184
}
@@ -195,13 +195,13 @@ public DSPasswordAes valueOf(DSElement arg) {
195
195
* @param arg The text to hash.
196
196
* @return Returns the NULL instance if the arg is null or the empty string.
197
197
*/
198
- public static DSPasswordAes valueOf (String arg ) {
198
+ public static DSPasswordAes256 valueOf (String arg ) {
199
199
if (arg == null ) {
200
200
return NULL ;
201
201
} else if (arg .isEmpty ()) {
202
202
return NULL ;
203
203
}
204
- return new DSPasswordAes (encode (arg ));
204
+ return new DSPasswordAes256 (encode (arg ));
205
205
}
206
206
207
207
// Initialization
@@ -210,14 +210,14 @@ public static DSPasswordAes valueOf(String arg) {
210
210
static {
211
211
try {
212
212
cipher = Cipher .getInstance ("AES/ECB/PKCS5Padding" );
213
- byte [] nameBytes = DSPasswordAes .class .getName ().getBytes (DSString .UTF8 );
214
- byte [] keyBytes = new byte [16 ];
215
- System .arraycopy (nameBytes , 0 , keyBytes , 0 , 16 );
213
+ byte [] nameBytes = DSPasswordAes256 .class .getName ().getBytes (DSString .UTF8 );
214
+ byte [] keyBytes = new byte [32 ];
215
+ System .arraycopy (nameBytes , 0 , keyBytes , 0 , 32 );
216
216
key = new SecretKeySpec (keyBytes , "AES" );
217
217
} catch (Exception x ) {
218
218
Logger .getLogger ("security" ).log (Level .SEVERE , "AES problem" , x );
219
219
}
220
- DSRegistry .registerDecoder (DSPasswordAes .class , NULL );
220
+ DSRegistry .registerDecoder (DSPasswordAes256 .class , NULL );
221
221
}
222
222
223
223
}
0 commit comments