V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
2ME
V2EX  ›  程序员

CryptoJS 和 Golang pbkdf2 加密问题

  •  
  •   2ME · Dec 15, 2020 · 1563 views
    This topic created in 1969 days ago, the information mentioned may be changed or developed.

    目前有个字段现在是用 CryptoJS pbkdf2 加密的 现在业务迁移到 Golang 同样的参数 最后结果不一致 对 JS 代码不熟悉 想请教下是什么问题

    后面还有 AES 相关的代码迁移 不知道是否还会出现同样的问题

    boboliu
        1
    boboliu  
       Dec 15, 2020   ❤️ 1
    1. pbkdf2 是 kdf,不是加密的
    2. salt 保持一致,注意看下编码问题
    3. cryptojs 默认 iter = 1,可能需要注意这个参数
    neoblackcap
        2
    neoblackcap  
       Dec 15, 2020
    AES 如果 key 啥的都正确,iv 也有了,解密错误,那么就是你的错
    AES 不管用什么语言加密解密都是可以的。这个我对接过很多 API 了。
    2ME
        3
    2ME  
    OP
       Dec 15, 2020
    @boboliu 非常感谢 经过排查是 salt 的编码问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5756 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 06:50 · PVG 14:50 · LAX 23:50 · JFK 02:50
    ♥ Do have faith in what you're doing.