如何散列密码 [英] How to hash a password

查看:130
本文介绍了如何散列密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哎,
   我想存储在手机上输入密码的哈希值,但我不知道该怎么做。我只能似乎找到加密方法。什么是哈希密码的最佳方式?
谢谢

hey, I'd like to store the hash of a password on the phone, but I'm not sure how to do it. I can only seem to find encryption methods. What's the best way to hash the password? thanks

推荐答案

您可以使用

var md5 = new MD5CryptoServiceProvider();
var md5data = md5.ComputeHash(data);

var sha1 = new SHA1CryptoServiceProvider();
var sha1data = sha1.ComputeHash(data);

要获得数据的字节数组,你可以使用

To get data as byte array you could use

var data = Encoding.ASCII.GetBytes(password);

和从取回字符串 md5data sha1data

var hashedPassword = ASCIIEncoding.GetString(md5data);

这篇关于如何散列密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆