How should i write this code to make it work

using System;
using System.Net.Http.Headers;
using System.Security.Cryptography;

public static string CreateNewRelicID()
    var guidBytes = Guid.NewGuid().ToByteArray();
    var base64Guid = Convert.ToBase64String(guidBytes);

    using (var md5 = MD5.Create())
        var hashBytes = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(base64Guid));
        var base64Hash = Convert.ToBase64String(hashBytes);

        return $"{base64Guid}.{base64Hash}";

and I want to get the result in NewRelic variable

Here I write this on Nodejs . Paste this on Js script block and output define as rid (string)

const crypto = require('crypto');

function createNewRelicID() {
  const guidBytes = crypto.randomBytes(16);
  const base64Guid = guidBytes.toString('base64');

  const md5 = crypto.createHash('md5');
  const hashBytes = md5.update(base64Guid, 'utf8').digest();
  const base64Hash = hashBytes.toString('base64');

  return `${base64Guid}.${base64Hash}`;

var rid = createNewRelicID()

1 Like