Sorry - Just noticed I sent it to Christian only instead of to the group as well. Resending. ==== Hi Christian, Thanks for the quick reply. The attacked CSV is very small. I've also included the test query file. As mentioned, I'd like to encrypt the CK field (so that it's saved to the file as encrypted). Thanks, Noam On Mon, Jun 22, 2015 at 11:30 AM, Christian Grün <christian.gruen@gmail.com> wrote:
Hi Noam,
Could you please provide us with a self-contained example (the smaller, the better [1])?
Thanks in advance, Christian
On Mon, Jun 22, 2015 at 10:09 AM, Noam Green <green.noam@gmail.com> wrote:
Hi all,
I'm using the following xquery (after being helped by Christian).
declare variable $in external; declare variable $out external; declare variable $vendor external;
let $options := map { 'header': true() } let $text := file:read-text($in) let $xml := csv:parse($text, $options)
let $result := <csv>{ for $record in $xml//record[contains(VENDORS, $vendor) and not(contains(HOST, "Non external")) and not(empty(HOST))]
return <record>{
$record/(HOST, PATH, ATTACKCOUNT, TIME_STAMP,CK) }</record>
}</csv> return file:write-text($out, csv:serialize($result, $options))
I would like to have one of the returned records encrypted. How do I change that record before saving it? I tried: return <record>{
crypto:encrypt($record/CK, 'symmetric','keykeyke','DES'), $record/(HOST, PATH, ATTACKCOUNT, TIME_STAMP,CK) }</record>
But that doesn't really change the CK field. I can't seem to modify anything in the $record/(HOST, PATH, ATTACKCOUNT, TIME_STAMP,CK).
Any thoughts? Thanks, Noam
Hi Noam, The crypto:encrypt function returns the result as a string, so you'll need to wrap it with an additional element: return <record>{ <CK>{ crypto:encrypt(...) }</CK>, ... }</record> However, the returned string will contain non-ASCII characters, so it may not be what you expect, so you could possibly encode it as Base64: convert:string-to-base64( ... ) Hope this helps, Christian
Hi Christian, As usual - fast and accurate response. Worked thanks! What I guess I was missing is the <CK>{ } </CK> notation (all these little FLOWR tricks I can't seem to find anywhere). Thanks again, Noam On Mon, Jun 22, 2015 at 1:52 PM, Christian Grün <christian.gruen@gmail.com> wrote:
Hi Noam,
The crypto:encrypt function returns the result as a string, so you'll need to wrap it with an additional element:
return <record>{ <CK>{ crypto:encrypt(...) }</CK>, ... }</record>
However, the returned string will contain non-ASCII characters, so it may not be what you expect, so you could possibly encode it as Base64:
convert:string-to-base64( ... )
Hope this helps, Christian
participants (2)
-
Christian Grün -
Noam Green