Dear all, I try to make the result of the encryption readable by converting the result either in Base64 or in Hex. Yet I am not able to convert it back to be able to decrypt. Could you help me ? André Bovy let $encrypted := crypto:encrypt('message', 'symmetric','keykeyke','DES’) let $base64 := string(convert:string-to-base64($encrypted)) let $encrypted := convert:binary-to-string(xs:base64Binary($base64)) (: generates invalid characters :) return crypto:decrypt($encrypted, 'symmetric','keykeyke','DES')
Hi Andre, The crypt:encrypt function is somewhat broken. As all XQuery strings need to be UTF8-encoded, it would have been correct to return an item of xs:base64Binary (the underlying specification had xs:boolean as actual return type). Due to this inconsistency, I am actually not sure if there is any proper way to get a readable representation of the result other than writing the file as string to disk and re-read it as binary: let $encrypted := crypto:encrypt('message', 'symmetric','keykeyke','DES') return ( file:write-text('tmp', $encrypted), file:read-binary('tmp') ) I feel that this should be changed with BaseX 9.3. I have opened a new issue [1]. Best, Christian [1] https://github.com/BaseXdb/basex/issues/1713 On Sun, Aug 11, 2019 at 9:57 AM Andre Bovy <andre.bovy@gmail.com> wrote:
Dear all,
I try to make the result of the encryption readable by converting the result either in Base64 or in Hex. Yet I am not able to convert it back to be able to decrypt.
Could you help me ?
André Bovy
let $encrypted := crypto:encrypt('message', 'symmetric','keykeyke','DES’) let $base64 := string(convert:string-to-base64($encrypted)) let $encrypted := convert:binary-to-string(xs:base64Binary($base64)) (: generates invalid characters :) return crypto:decrypt($encrypted, 'symmetric','keykeyke','DES')
Hi André, The functions of the Cryptographic Module have been updated with the latest snapshot [1]: crypto:encrypt will now return an item of type xs:base64Binary. In addition, all data and key arguments can now be strings or binary items. Feel free to check out the latest snapshot [2]. Best, Christian [1] http://docs.basex.org/wiki/Cryptographic_Module#crypto:decrypt [2] http://files.basex.org/releases/latest/ On Sun, Aug 11, 2019 at 9:57 AM Andre Bovy <andre.bovy@gmail.com> wrote:
Dear all,
I try to make the result of the encryption readable by converting the result either in Base64 or in Hex. Yet I am not able to convert it back to be able to decrypt.
Could you help me ?
André Bovy
let $encrypted := crypto:encrypt('message', 'symmetric','keykeyke','DES’) let $base64 := string(convert:string-to-base64($encrypted)) let $encrypted := convert:binary-to-string(xs:base64Binary($base64)) (: generates invalid characters :) return crypto:decrypt($encrypted, 'symmetric','keykeyke','DES')
participants (2)
-
Andre Bovy -
Christian Grün