Forum Discussion
Decrypt string values from a column of a table in a query
- 7 years ago
Hi Sarazin73,
I've written a custom function for you:
fnXorCrypt = ( string as text, xorValue as number ) as text => // concat encrypted characters List.Accumulate( // get a list of chars Text.ToList(string), // initial string "", // accumulate last state and a new encrypted character (state, current) => state & Character.FromNumber( Number.BitwiseXor( Character.ToNumber(current), xorValue ) ) )The usage:
EncodedString = fnXorCrypt("Lundi", 42)A test:
Hi Sarazin73,
do you also have the decryption algorithm in c-like code? If I had one, I'd develop a function in M for you.
And can you please post some examples for testing?
Thank you :)
Hi,
Thanks for helphing me !
The algorythm used is the same to decryt than to encrypt. The initial outside script that crypt data as source is in java language. We have finally do tests with XOR 42 instead of XOR 24. Below, some samples with their corresponding encoding string.
Lundi : f_DNC
Mardi : gKXNC
Mercredi : gOXIXONC
Jeudi : `O_NC
Vendredi : |ODNXONC
Samedi : yKGONC
Dimanche : nCGKDIBO
- Nolock7 years ago
Resident Rockstar
Hi Sarazin73,
I've written a custom function for you:
fnXorCrypt = ( string as text, xorValue as number ) as text => // concat encrypted characters List.Accumulate( // get a list of chars Text.ToList(string), // initial string "", // accumulate last state and a new encrypted character (state, current) => state & Character.FromNumber( Number.BitwiseXor( Character.ToNumber(current), xorValue ) ) )The usage:
EncodedString = fnXorCrypt("Lundi", 42)A test:
- Sarazin737 years agoFrequent Visitor
Hi NoLock,
thanks for your job. It's perfect !