Ruby 求解,encrypt 加密之后的结果是乱码?

wccxiaoan · October 18, 2012 · 3783 hits

先上代码:

def encrypt key,data cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc") cipher.encrypt cipher.key = key cipher.update(data) + cipher.final end

# 这里我获得了一个 token,是经过 Base64 encode 过的 token = Base64.encode64 OpenSSL::HMAC.digest("SHA1", str,salt) # 这里使用上面的加密,获得 secret_token secret_token = encrypt(key,token) # => "C▒▒q▒X`▒▒)▒ѵ▒4▒Dv-▒/▒D▒▒z▒"

结果如上,secret_token 是乱码。。有明白人指教一下吗?

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.