mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
initial add of EbeanORM server based on v2.8.1
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.avaje.tests.unitinternal;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Arrays;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.avaje.ebean.config.EncryptKey;
|
||||
import com.avaje.ebeaninternal.server.type.SimpleAesEncryptor;
|
||||
import com.avaje.tests.basic.encrypt.BasicEncryptKey;
|
||||
|
||||
public class TestSimpleEncryptor extends TestCase {
|
||||
|
||||
|
||||
public void test() {
|
||||
|
||||
SimpleAesEncryptor e = new SimpleAesEncryptor();
|
||||
|
||||
EncryptKey key = new BasicEncryptKey("hello");
|
||||
|
||||
byte[] data = "test123".getBytes();
|
||||
|
||||
byte[] ecData = e.encrypt(data, key);
|
||||
System.out.println(Arrays.toString(ecData));
|
||||
|
||||
byte[] deData = e.decrypt(ecData, key);
|
||||
|
||||
String s = new String(deData);
|
||||
|
||||
System.out.println(s);
|
||||
|
||||
Timestamp t = new Timestamp(System.currentTimeMillis());
|
||||
byte[] ecTimestamp = e.encryptString(t.toString(), key);
|
||||
System.out.println(t+" encrypted -> "+Arrays.toString(ecTimestamp));
|
||||
|
||||
String tsFormat = e.decryptString(ecTimestamp, key);
|
||||
Timestamp t1 = Timestamp.valueOf(tsFormat);
|
||||
Assert.assertEquals(t, t1);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user