2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Rust Crypto】RustでSHA256ハッシュ値を得る方法

Last updated at Posted at 2024-04-08

RustCrypto: SHA-2

Pure Rust and NO stdで書かれたクレートです。
creates

使い方

コマンドラインでクレート追加します

cargo add sha2

こんな感じで結構シンプルに使えます

use sha2::{Digest, Sha256};

fn main() {
    let data = b"hello world";
    let hash = Sha256::digest(data);
    println!("{:x}", hash);
}

hash: b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9

今回紹介したsha256の他に

  • SHA-224
  • SHA-256
  • SHA-384
  • SHA-512

があります。

Rustのsha256のハッシュ値求めるやり方の記事が見当たらなかったので書いてみました。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?