Applescript中的字符x到y

时间:2015-05-12 18:43:22

标签: applescript

我正在编写一个AppleScript,它会生成一个随机数,然后插入一个字符串之间,类似于密码盐(但不是真的)。这是我的代码:

    set passSalt to random number from 10000000 to 99999999
    do shell script "echo password | shasum -a 512"
    set passHash to result
    set cutHash1 to random number from 1 to 32
    set cutHash2 to random number from 33 to 64
    set cutHash3 to random number from 65 to 96
    set cutHash4 to random number from 97 to 128
    set combinedHash1 to characters cutHash1 through cutHash2 of passHash
    set combinedHash2 to characters cutHash3 through cutHash4 of passHash
    set finalHash to combinedHash1 and finalSalt and combinedHash2

它的作用是生成一个随机数并将其插入到散列版密码的两个随机位置之间。在最后一行,它返回

  

无法使{" 1"," 9"," f"," 9"," c&# 34;," c"," a"," a"," 4"," d",&# 34; 6"," b"," 3"," 7"," a"," 6&#34 ;," a"," 2"," 4"," 3"," d",&#34 ; b"," e"," 0"," f"," 2"," 3" ," 1"," 3"," 7"," b"," 1"}进入类型布尔值。

我做错了什么?

1 个答案:

答案 0 :(得分:1)

将最后一行中的每个“and”更改为“&”。在Applescript中,“and”用于组合两个布尔值,而“&”用于连接。

您可能还希望将“finalHash”作为文本而不是列表返回:

set finalHash to (combinedHash1 & finalSalt & combinedHash2) as text

我假设你在代码的其他地方定义了“finalSalt”。