相关疑难解决方法(0)

如何将字节数组转换为十六进制字符串,反之亦然?

如何将字节数组转换为十六进制字符串,反之亦然?

c# arrays hex

1313
推荐指数
24
解决办法
81万
查看次数

获取字符串的SHA-256字符串

我有一些string,我想用使用C#的SHA-256哈希函数来哈希它.我想要这样的东西:

 string hashString = sha256_hash("samplestring");
Run Code Online (Sandbox Code Playgroud)

框架中是否有内置功能可以执行此操作?

c# string hash sha256

37
推荐指数
2
解决办法
6万
查看次数

我从clojure和python中获得了略微不同的hmac签名

我从我的python实现获得的HMAC SHA1签名和我的clojure实现略有不同.我很难过会导致这种情况.

Python实现:

import hashlib
import hmac

print hmac.new("my-key", "my-data", hashlib.sha1).hexdigest() # 8bcd5631480093f0b00bd072ead42c032eb31059
Run Code Online (Sandbox Code Playgroud)

Clojure实施:

(ns my-project.hmac
    (:import (javax.crypto Mac)
         (javax.crypto.spec SecretKeySpec)))

(def algorithm "HmacSHA1")

(defn return-signing-key [key mac]
  "Get an hmac key from the raw key bytes given some 'mac' algorithm.
  Known 'mac' options: HmacSHA1"
    (SecretKeySpec. (.getBytes key) (.getAlgorithm mac)))

(defn sign-to-bytes [key string]
  "Returns the byte signature of a string with a given key, using a SHA1 HMAC."
  (let [mac (Mac/getInstance algorithm)
    secretKey (return-signing-key key mac)]
    (-> (doto mac …
Run Code Online (Sandbox Code Playgroud)

python cryptography clojure hmac

2
推荐指数
1
解决办法
405
查看次数

标签 统计

c# ×2

arrays ×1

clojure ×1

cryptography ×1

hash ×1

hex ×1

hmac ×1

python ×1

sha256 ×1

string ×1