2016-09-13 21 views
0

我需要哈希鍵,我發現Google Script提供了這個方法的關鍵:https://developers.google.com/apps-script/reference/utilities/utilities#computeHmacSha256Signature%28String,String%29散列和非散列與谷歌腳本

但我怎麼能取消哈希鍵與方法計算?

這裏是我試過的事情:

var my_key = "g1w9625bf43bfd91s6c2095c1w160699a59m72t" 
    var hash = Utilities.computeHmacSha256Signature("this", my_key); 

    var un_hash = Utilities.base64Decode(hash); 

散列函數的工作原理,但un_hash返回我Could not decode string

我很感激任何幫助。

回答

0

散列不能顛倒。你不應該能夠散列哈希。 正如您在下圖中看到的,多個值可能具有相同的散列值。

如果您將散列計算爲「02」,則永遠無法知道這個散列是在「John Smith」還是「Sandra Dee」上計算的。這些信息並不存在。

enter image description here https://en.wikipedia.org/wiki/File:Hash_table_4_1_1_0_0_1_0_LL.svg