cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
eddydm Member
Member

Privacy - Hashing of keys

Hey,

 

 

In a powerbi-file i have some related tables. Some of the relations uses a key which contains specific personal-related-information, which may not be visable to 'the whole world' (privacy rules.)

I want to hash this key and use this hashed values in the relations.

 

Some questions:

* is the hashing of the key possible?

* Can some give me an example how to calculate this hashing. I like to use dax-formulas, not the r-scripting.

 

 

Kind regards

 

 

Eddy

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Privacy - Hashing of keys

Hi @eddydm,

 

I haven't find any function to directly convert the string to hash string (dax and power query not contain).

 

For your requirement, you can try to use below methods if it works on your side:

 

1. T-sql.

 

Use a static string to instead of the privacy information or use hasbytes to transform.

 

Capture.PNG

 

2. R script.

Write a r script which use to convert the string, then run it in query editor.

 

3. Web.Content.

Add a custom step which use to call a transform string api/webservice.

 

Reference links:

HASHBYTES (Transact-SQL)

Using R in Query Editor

Web.Contents

Power Query Functions–Some Scenarios

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



For learning resources/Release notes, please visit: | |
2 REPLIES 2
Community Support Team
Community Support Team

Re: Privacy - Hashing of keys

Hi @eddydm,

 

I haven't find any function to directly convert the string to hash string (dax and power query not contain).

 

For your requirement, you can try to use below methods if it works on your side:

 

1. T-sql.

 

Use a static string to instead of the privacy information or use hasbytes to transform.

 

Capture.PNG

 

2. R script.

Write a r script which use to convert the string, then run it in query editor.

 

3. Web.Content.

Add a custom step which use to call a transform string api/webservice.

 

Reference links:

HASHBYTES (Transact-SQL)

Using R in Query Editor

Web.Contents

Power Query Functions–Some Scenarios

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



For learning resources/Release notes, please visit: | |
Highlighted

Re: Privacy - Hashing of keys

Old thread, but I had a similar need and I've found a pure Power Query/M solution to this...

 

M can compress binary data as gzip, the gzip footer contains a 32-bit CRC checksum which we can access and use as a uniformly sized hash:

 

CalculateHash = (x as text) as number => BinaryFormat.UnsignedInteger32(
    Binary.FromList(
        List.FirstN(
            List.LastN(
                Binary.ToList(
                    Binary.Compress(Text.ToBinary(x, BinaryEncoding.Base64), Compression.GZip)
                ),
            8), 
        4)
    )
)

The footer is 8 bytes, the first 4 of which contains the checksum. We convert the gzip binary to a list in order to extract the relevant bytes and in turn convert this to a non-negative number. Alternatively, you could use the hex value for a text hash:

 

CalculateHash = (x as text) as text => Binary.ToText(
    Binary.FromList(
        List.FirstN(
            List.LastN(
                Binary.ToList(
                    Binary.Compress(Text.ToBinary(x, BinaryEncoding.Base64), Compression.GZip)
                ),
            8), 
        4)
     ),
BinaryEncoding.Hex)

 

Helpful resources

Announcements
Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Power BI Helps Homeless and Trouble Youth

Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 188 members 2,194 guests
Please welcome our newest community members: