需要帮助将C#代码转换为javascript /反转函数输出

时间:2017-03-05 22:34:55

标签: javascript c#

我正在处理一个将数字转换为字符串,将字符串转换为数字的函数。

原始的c#代码

(Parameter.set 'Audio_Required_Format 'aiff)
(Parameter.set 'Audio_Method 'Audio_Command)
(Parameter.set 'Audio_Command "paplay $FILE --client-name=Festival --stream-name=Speech")

javascript代码 这是正常的,因为它将字符串转换为我想要的哈希

public static string unhash(Int64 hash)
{
    string originalString = "";
    Int64 mod = 37;
    string letters = "acdegilmnoprstuw";
    while (hash != 7)
    {
        Int64 index = hash % mod;
        originalString = letters[(Int32) index] + originalString; // need help converting this line to javascript
        hash = (hash - index) / mod;
    }
    return originalString;
}

用于将哈希进程反转为字符串的代码,它无法正常工作

function hash (s) {
    var h = 7;
    var  letters = "acdegilmnoprstuw";
    for (i = 0; i < s.length; i++) {
        h = (h * 37 + letters.indexOf(s[i]))
    }
    return h;
}

0 个答案:

没有答案