Forum Discussion

sontt's avatar
sontt
Resolver I
8 years ago
Solved

Convert R script to powerbi function

Hi there   I try convert my string to sha256 with r-script function:   library(digest) apikey <- "hello" apimessage <-"world" hash <- digest::hmac(apikey,apimessage, algo="sha256", serialize=F...
  • v-yuta-msft's avatar
    8 years ago

    Hi sontt,

     

    To achieve your requirement, please refer to R Script:

     

    # 'dataset' holds the input data for this script

    library(digest)

     

    len <- length(dataset[[1]])

    hash <- c()

    for (i in 1:len) {

        hash <- append(hash, digest::hmac(dataset[i, 1],dataset[i, 2], algo="sha256", serialize=F))

    }

    dataset$hash <- hash

    result <- dataset

     

     

    The result is like below and you can refer to PBIX file here:

    https://www.dropbox.com/s/ykto8cwdrwg2gl8/For%20sontt.pbix?dl=0

     

     

    Best Regards,

    Jimmy Tao