Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Decrypt Values from Sharpoint List

Hello,

I just started in the world of Power BI and now im facing a challenge.

In a sharepoint list I am storing values which are encrypted using a function within MS Access. Now I want to use this data in power bi and I am struggeling getting the data decrypted 😕

 

The VBA Code works fine in MSAccess

 

Public Const CodeKey As String = 1234#




Public Function XORDecryption(DataIn As String) As String

For arkdata1 = 1 To (Len(DataIn) / 2)

intXOrValue1 = Val("&H" & (Mid$(DataIn, (2 * arkdata1) - 1, 2)))

intXOrValue2 = Asc(Mid$(CodeKey, ((arkdata1 Mod Len(CodeKey)) + 1), 1))

strDataOut = strDataOut + Chr(intXOrValue1 Xor intXOrValue2)

Next arkdata1

XORDecryption = strDataOut

End Function

 

Results:

Input: "hello"

encryption("hello"): 5A56585D5D

decryption("5A56585D5D"): hello

 

How can i do in Power Query (or do I need a DAX function?) to decrypt the content for each row?

So far I was not even able to find the corresponding functions that are used in the VBA function..

I saw a similar post but as this is using a different function its not helping me to get this working.

 

Thanks a lot for your support!

1 ACCEPTED SOLUTION

Looks like I didn't properly translate the VBA text offset with the Power Query offset.

 

This should work:

= (DataIn as text) as text =>
let
   asBinary = Binary.FromText(DataIn, BinaryEncoding.Hex),
   numbers = Binary.ToList(asBinary),
   xored = List.Transform({0 .. List.Count(numbers) - 1}, each 
      Number.BitwiseXor(numbers{_}, Character.ToNumber(Text.At(CodeKey, Number.Mod(_ + 1, Text.Length(CodeKey)))))
   ),
   asDecodedBinary = Binary.FromList(xored),
   asText = Text.FromBinary(asDecodedBinary, TextEncoding.Ascii)
in
   asText

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Thanks a lot for the great support!

 

artemus
Microsoft Employee
Microsoft Employee

The function would look something like (input into advanced editor after creating a blank query):

(DataIn as text) as text =>
let
   asBinary = Binary.FromText(DataIn, BinaryEncoding.Hex),
   numbers = Binary.ToList(asBinary),
   xored = List.Transform({0 .. List.Count(numbers) - 1}, each 
      Number.BitwiseXor(numbers{_}, Character.ToNumber(Text.At(CodeKey, Number.Mod(_, Text.Length(CodeKey)))))
   ),
   asDecodedBinary = Binary.FromList(xored),
   asText = Text.FromBinary(asDecodedBinary, TextEncoding.Ascii)
in
   asText

 

However, without the CodeKey, I can't check if this works or not.

 

Anonymous
Not applicable

Thanks a lot for your support!

 

The CodeKey is the very first line (1234) of the code section. 

I added the function with the line 

 CodeKey = Text.Proper("1234#"),
(with # and without # as this doesn't make a difference within VBA)

When Using the function with the input 5A56585D5D the result is kdkil instead of hello

 

Any Idea what I made wrong?

 

Icey
Community Support
Community Support

Hi @Anonymous ,

 


 

 CodeKey = Text.Proper("1234#"),
(with # and without # as this doesn't make a difference within VBA)

 


One note:

In Power Query Editor, with "#" and without "#" is not the same. When using @artemus 's method, it is needed to remove "#" in your expression.

 

 

Best regards

Icey

 

If this post helps, then consider Accepting it as the solution to help other members find it faster.

Looks like I didn't properly translate the VBA text offset with the Power Query offset.

 

This should work:

= (DataIn as text) as text =>
let
   asBinary = Binary.FromText(DataIn, BinaryEncoding.Hex),
   numbers = Binary.ToList(asBinary),
   xored = List.Transform({0 .. List.Count(numbers) - 1}, each 
      Number.BitwiseXor(numbers{_}, Character.ToNumber(Text.At(CodeKey, Number.Mod(_ + 1, Text.Length(CodeKey)))))
   ),
   asDecodedBinary = Binary.FromList(xored),
   asText = Text.FromBinary(asDecodedBinary, TextEncoding.Ascii)
in
   asText

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.