Pages: [1]
  Print  
Author Topic: [Solved] Encode String as Base64  (Read 1801 times)
JEdward
Jr. Member
**
Posts: 86


« on: August 09, 2013, 12:13:17 PM »

Hello,

I'd like to take an attribute value and encode it as base64, does anyone have any suggestions on how to do this using the Execute Script or another operator?

I'm struggling. 

Thanks,
JH
« Last Edit: August 09, 2013, 12:26:42 PM by JEdward » Logged
JEdward
Jr. Member
**
Posts: 86


« Reply #1 on: August 09, 2013, 12:26:21 PM »

Solved it!  For anyone wanting to do the same, you can use the following code in the Execute Script operator. 

Code:
ExampleSet eSet = operator.getInput(ExampleSet.class);
for (Example example : eSet) {
def s = example["Attribute Value"]
String encoded = s.bytes.encodeBase64().toString()
example["Attribute Value"] = encoded
}

return eSet;
Logged
Pages: [1]
  Print  
 
Jump to: