use of com.dexels.navajo.functions.security.Security in project navajo by Dexels.
the class DecryptString method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
String result = null;
String key = (String) getOperand(0);
String message = (String) getOperand(1);
try {
Security s = new Security(key);
result = s.decrypt(message);
} catch (Exception e) {
throw new TMLExpressionException(e.getMessage(), e);
}
return result;
}
use of com.dexels.navajo.functions.security.Security in project navajo by Dexels.
the class DecryptBinary method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
Binary result = null;
String key = (String) getOperand(0);
String message = (String) getOperand(1);
try {
Security s = new Security(key);
result = s.decryptBinary(message);
} catch (Exception e) {
throw new TMLExpressionException(e.getMessage());
}
return result;
}
use of com.dexels.navajo.functions.security.Security in project navajo by Dexels.
the class EncryptString method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
String result = null;
String key = (String) getOperand(0);
String message = (String) getOperand(1);
try {
Security s = new Security(key);
result = s.encrypt(message).replace("\n", "");
} catch (Exception e) {
throw new TMLExpressionException(e.getMessage());
}
return result;
}
use of com.dexels.navajo.functions.security.Security in project navajo by Dexels.
the class EncryptBinary method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
String result = null;
String key = (String) getOperand(0);
Binary image = (Binary) getOperand(1);
try {
Security s = new Security(key);
result = s.encrypt(image).replace("\n", "");
} catch (Exception e) {
throw new TMLExpressionException(e.getMessage());
}
return result;
}
use of com.dexels.navajo.functions.security.Security in project navajo by Dexels.
the class TestEncryptBinary method testEncryptBinary.
@Test
public void testEncryptBinary() throws Exception {
Security s = new Security("A");
File f = new File("test");
FileOutputStream fos = new FileOutputStream(f);
fos.write("Content".getBytes());
fos.close();
Binary b = new Binary(new FileInputStream(f));
String enc = s.encrypt(b);
System.err.println("enc: " + enc);
Binary b2 = s.decryptBinary(enc);
BufferedReader is = new BufferedReader(new InputStreamReader(b2.getDataAsStream(), "UTF-8"));
String l = is.readLine();
is.close();
Assert.assertEquals("Content", l);
f.delete();
}
Aggregations