Powershell hash tables and PSObjects – multiple values

I need help with the following for my project in SharePoint. I have an external list with values like:

*ToolId*                   *ProductId*  T001                       ProductA T001                       ProductB T002                       ProductA T002                       ProductC 

I use PowerShell to exort that list into a CSV. I need to manipulate the external list and my final result needs to be like that:

*ToolId*                 *ProductId*  T001                     ProductA; ProductB T002                     ProductA; ProductC 

This is my PS code so far:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue   #Get the context $  ctx = Get-SPServiceContext https://path  #Get the scope $  scope = new-object Microsoft.SharePoint.SPServiceContextScope $  ctx  #Get the target site collection  $  webTarget = Get-SPWeb -identity "https://path"  #Get the Target List  $  list = $  webTarget.Lists["Name of List"]   #Array to Hold Result - PSObjects  $  ListItemCollection = @()   #Get All List items  $  list.Items |  Where-Object { $  _["ToolId"] -ne ''} | foreach {  $  ExportItem = New-Object PSObject $  ExportItem | Add-Member -MemberType NoteProperty -name "ToolId" -value    $  _["ToolId"] $  ExportItem | Add-Member -MemberType NoteProperty -name "ProductId" -value $  _["ProductId"]   #Add the object with property to an Array  $  ListItemCollection += $  ExportItem }  #Export the result Array to CSV file  $  ListItemCollection | Export-CSV "\path\test.csv" -NoTypeInformation                         #Dispose the web Object  $  webTarget.Dispose() 

I’m having problems with PSObjects and hash tables to get all the items of the same ToolId and collect all the ProductId’s relevant to them to populate my CSV.

Is there any advantage to combining a hash algorithm with a key-derivation function?

Let’s assume I would like to secure passwords using a modern KDF such as Argon2. The flow of information would look like this: $ hash,$ salt = argon2id($ password, $ salt).

Is there any advantage to first hash the password using SHA256/512, like so $ hash,$ salt = argon2id(sha256($ password), $ salt)?

How to implement hash based navigation on a D8 site?

So the specific functionality I’m looking for is a link on one page (e.g. drupalsite/home) leading directly to a specific section of another page (e.g. a section on drupalsite/otherpage).

I believe that to implement this I need to use hash based navigation such that the content I want to link to is has it’s css class name preceded by a hash (pound sign or number symbol) <div class="#mydiv"> and is linked to by including the hash referenced content in the href attribute of an anchor tag. Such that <div class="#mydiv"> on page drupalsite/mypage via <a href="/mypage#mydiv">. Will this work without out of the box with just html changes? Or is additional jquery configuration necessary? I know that more specific and fluid implementations will necessitate JS and JQuery, but I want to know if the core html functionality works without conflicting with Drupal’s internals?

Qual seria um um bom algoritmo de cálculo hash?

Na pergunta Por que o hashCode() de String em Java usa 31 como multiplicador? fala-se do uso do número 31 como multiplicador. Foi posta uma controvérsia sobre a motivação deste número. De fato ele não é considerado tão bom. Qual seria um número bom? Por que?

Mais ainda, o que uma função de cálculo hash deve ter para ser considerado boa? Eu sei que ela deve gerar poucas colisões de códigos hash, eu queria saber o que deve ser observado nela para ser considerada boa. Eu já vi muita gente alegando que sua função hash é muito boa, mas são bem diferentes umas das outras, fico pensando se isto é subjetivo, mas não deveria ser, me parece algo bem matemático.

Ketama hash explanation

(I originally posted this on stackoverflow but thought it would be a better fit here)

I’m trying to understand the Ketama hash code used in consistent hashing.

link and snippet below:

public static Long md5HashingAlg(String key) {     MessageDigest md5 = null;     try {         md5 = MessageDigest.getInstance("MD5");     } catch (NoSuchAlgorithmException e) {         log.error("++++ no md5 algorythm found");         throw new IllegalStateException("++++ no md5 algorythm found");     }     md5.reset();     md5.update(key.getBytes());     byte[] bKey = md5.digest();     long res = ((long) (bKey[3] & 0xFF) << 24)         | ((long) (bKey[2] & 0xFF) << 16)         | ((long) (bKey[1] & 0xFF) << 8) | (long) (bKey[0] & 0xFF);      return res; } 

I think I understand what the code is doing, but I don’t get why they’re doing it. Particularly, I’m wondering why:

  1. the code discards the least significant 8 bytes of the 16-byte MD5 and uses only the first four (bKey[0] through bKey[3]).

  2. the code “flips” the significant bytes meaning that, of the 4 bytes from 1., the least significant now become the most significant (at least that’s what I understand happens from the & 0xffs and left shifts).

I also came across another piece of code that uses the same logic as above, but in addition performs an & 0xffffffffL on the result to “truncate to 32-bits”.

link and snippet:

case KETAMA_HASH:     byte[] bKey = computeMd5(k);     rv = ((long) (bKey[3] & 0xFF) << 24)         | ((long) (bKey[2] & 0xFF) << 16)         | ((long) (bKey[1] & 0xFF) << 8)         | (bKey[0] & 0xFF);     break;     default:     assert false; }  return rv & 0xffffffffL; /* Truncate to 32-bits */ 

Could someone help me understand the rationale behind picking these particular bytes and re-arranging them in this particular fashion?

additive hash function

Do functions with the following properties exists for x being arbitrary stream of bytes:

  1. op(f(x1), f(x2))=f(x1+x2) and op(f(x1), f(x2))!=f(x2+x1) where plus denotes concatenation and op is an easily computable operation
  2. f(x) is fixed length of about 160-512 bytes
  3. f does not need to be hard to revert, but should be useful at finding transmission errors or duplicates.

Could you provide any names/articles/pointers?

Why is a 32 character hex string not a md5 hash?

This string, when dropped into hash detection tools, is not being identified as a hash. As far as I knew, an md5 has was a 32 digit string with hex numbers. Everything below is hex. So what other rules does md5 have that prevent this from being a hash?


Here is just one example of an ID failure for this string:


“Your hash may be one of the following : Sorry we cannot identify your hash..”

Why does VirusTotal have two different reports for the same hash depending on FILE vs URL submission?

Why would the same SHA256 Hash of a file have totally different VirusTotal results at the same time?

Submitting a file to VirusTotal via File upload results in numerous hits for malware.
Submitting the exact same file but via URL submission results in a totally safe and clean submission.

I understand that these files are accessed in different ways, so AV software might look at the file in a different context, but ultimately the endpoint is at risk regardless.