【问题标题】:Can't pass variable to secure-hash无法将变量传递给安全哈希
【发布时间】:2021-07-13 19:57:07
【问题描述】:

为什么当我在第二次调用中使用变量时,secure-hash 会失败? Emacs 27.1、27.2 和 26.3

(setq mytext "test")
(message (secure-hash 'sha256' mytext))
(message (secure-hash 'sha256' "test"))

【问题讨论】:

    标签: elisp


    【解决方案1】:

    mytext 之前有一个额外的quote ',这会阻止对mytext 变量的评估。

    以下工作正常:

    (let ((mytext "test"))
      (secure-hash 'sha256 mytext))
    ==> "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
    (secure-hash 'sha256 "test")
    ==> "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
    

    PS。如果您是 Lisp 新手,而且这不仅仅是一个错字,那么阅读 "An Introduction to Programming in Emacs Lisp" 会让您受益匪浅。 最好的方法是在 Emacs 中:C-h i m intro TAB RET.

    【讨论】:

    • 非常感谢!那成功了。我对 lisp 并不完全陌生,但我确实在它中大吃一惊,因为我很少用它编程。
    猜你喜欢
    • 1970-01-01
    • 2016-08-13
    • 2013-11-27
    • 2012-08-25
    • 1970-01-01
    • 2020-09-09
    • 2020-06-14
    • 2013-09-04
    相关资源
    最近更新 更多