实时搜索: md5如何加密

md5如何加密

516条评论 3575人喜欢 5634次阅读 838人点赞
我用PHP做系统。。。后台设置用户和密码。。。现在想在mysql中修改用户。。但修改完后。。用户不能登陆了。。。
我现在想在数据库中直接修改。。。我的情况是在数据库中修改完了。。用户就登不上。。。我想问如何在数据库中改。。。。 , //加密逻辑
if($data['password']){
$data['password']=md5($data['password']);
} , 关于C#中及ASP.NET、涉及到数据库中密码的安全性,这种问题不容小视,万一被别人获得数据库信息,就麻烦了!
在C#中如何把用户输入的密码进...

如何在mysql中修改md5加密过的用户密码: update table set password=md5('新密码') where .....

userid加密前:517421512 加密后: 34b4064721cfd717bf8aee1748f0e23b C#如何实现?: md5加密。

需要引用的命名空间
using System.Security.Cryptography;
using System.Text;

/// <summary>
/// 加密
/// </summary>
/// <param name="Md5Pwd">加密后的密码</param>
/// <param name="Pwd">需要加密的字段</param>
private static string Md5(ref string Md5Pwd, string Pwd)
{
MD5 md5 = MD5.Create();
// 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(Pwd));
// 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
for (int x = 0; x < s.Length; x++)
{
// 将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符
Md5Pwd = Md5Pwd + s[x].ToString("x");//得到加密后的密码
}
return Md5Pwd;
}

把需要加密的字段 传到这个方法里面就可以了。

thinkphp这个逻辑是如何执行加密了 是先执行md5($data['password'],然后在执行$data['password']=md5(..): 如果提交的数据里,password不为空,
对password进行md5加密: md5($data['password']);
加密后的字符串再赋值给password。

C#中怎样对输入的用户密码进行MD5加密,再与数据库中的经过加密的密码进行匹配?: 将取得的秘密 用md5进行加密, .net中自带的有这个System.Security.Cryptography.MD5 这个方法, 将数据加密之后再用.net中的管道程序和数据库中的md5值进行比较就ok了

如何实现对字节流的md5加密: public static byte[] getMD5(File file) { FileInputStream fis = null;//定义文件字节流 try { MessageDigest md = MessageDigest.getInstance("MD5");//创建MD5加密使用的对象 fis = new FileInputStream(file);//读取需要加密的文件,并封装...

如何将mysql数据库里的用户密码重置为MD5加密的密码: 如果已经对用户密码进行了password(str)处理,
想将它还原成str然后再MD5(str)处理,是无法实现的,
因为不论是password(str)还是MD5(str)都是不可逆的。

如何在PB中实现JAVA相同的MD5加密: 1、桥接模式的引入会增加系统的理解与设计难度,由于聚合关联关系建立在抽象层,要求开发者针对抽象进
2、桥接模式要求正确识别出系统中两个独立变化的维度,因此其使用范围具有一定的局限性。

如何取BLOB类型的MD5加密值: from ragini.deshpande
Here is the my_encryption package code ...........

CREATE OR REPLACE PACKAGE BODY my_encryption IS
/*
|| Local variable to hold the current encryption key.
*/
ps_encryption_key RAW(32);

/*
|| Local exception to hide Oracle -28231 Error Code.
*/
INTERNAL_BAD_KEY exception;
PRAGMA EXCEPTION_INIT(INTERNAL_BAD_KEY, -28231);

/*
|| Local exception to hide Oracle -28232 Error Code.
*/
INTERNAL_BAD_DATA exception;
PRAGMA EXCEPTION_INIT(INTERNAL_BAD_DATA, -28232);

/*
|| Local function to get the encryption key for a particular case.
*/
FUNCTION get_case_encryption_key(pi_cas_id IN ELS_CASES.ID%TYPE) RETURN RAW IS

/*
|| The key to be returned.
*/
key RAW(16);

/*
|| Cursor to return the case encyption key in encrypted format.
*/
CURSOR c_case_key(b_cas_id ELS_CASES.ID%TYPE) IS
SELECT encryption_key
FROM els_cases
WHERE id = b_cas_id;

BEGIN

OPEN c_case_key(pi_cas_id);
FETCH c_case_key INTO key;
CLOSE c_case_key;
RETURN key;

EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE NO_CASE;
END;

/*
|| Procedure to initialize package with the master key.
|| The master key will be held elsewhere from the database.
*/
PROCEDURE set_master_key(pi_key IN RAW) IS
BEGIN
IF LENGTHB(pi_key) != 32 THEN
RAISE BAD_KEY;
END IF;
ps_encryption_key := pi_key;
END;

/*
|| Procedure to initialize package with the master key.
|| Always returns 'Y'
|| The master key will be held elsewhere from the database.
*/
FUNCTION set_master_key(pi_key IN RAW) RETURN VARCHAR2 IS
BEGIN
set_master_key(pi_key);
RETURN 'Y';
END;

/*
|| Procedure to initialize package with the case encryption key.
*/
PROCEDURE set_case_key(pi_master_key IN RAW,
pi_cas_id IN ELS_CASES.ID%TYPE) IS
BEGIN
ps_encryption_key := pi_master_key;
ps_encryption_key := decrypt(pi_data=>get_case_encryption_key(pi_cas_id));
END;

/*
|| Function to initialize package with the case encryption key.
|| Always returns 'Y'
*/
FUNCTION set_case_key(pi_master_key IN RAW,
pi_cas_id IN ELS_CASES.ID%TYPE) RETURN VARCHAR2 IS
BEGIN
set_case_key(pi_master_key,pi_cas_id);
RETURN 'Y';
END;

/*
|| Function to encrypt data using the master key. Note the length of
|| pi_data, in bytes, must be at most 2000 bytes and be divisible by 8.
*/
FUNCTION encrypt(pi_data IN RAW) RETURN RAW IS
BEGIN
RETURN dbms_obfuscation_toolkit.DES3Encrypt(input => pi_data,
key => ps_encryption_key);
EXCEPTION
WHEN INTERNAL_BAD_DATA THEN
RAISE BAD_DATA;
WHEN INTERNAL_BAD_KEY THEN
RAISE BAD_KEY;
END;

/*
|| Function to encrypt a BLOB using the current encryption key.
*/
FUNCTION encrypt(pi_blob IN BLOB) RETURN BLOB IS

/*
|| Temporary blob variable to hold the encrypted contents.
*/
result blob;

/*
|| Variable to hold the length of the blob.
*/
blob_length PLS_INTEGER := dbms_lob.getlength(pi_blob);

/*
|| The Oracle encryption routines can only encrypt data whose length is <=2000.
*/
max_chunk_length PLS_INTEGER := 2000;

/*
|| Variable to hold the length of the current chunk that is being encrypted.
*/
chunk_length PLS_INTEGER;

/*
|| Variable to remember which how much of the input blob has been encrypted.
*/
pointer PLS_INTEGER := 1;

/*
|| Variable to hold the next bit of data to be encrypted.
*/
chunk RAW(2000);

/*
|| Variable to hold a pad byte used to pad the last chunk.
*/
pad RAW(1) := utl_raw.substr(utl_raw.cast_to_raw('0'),1,1);

BEGIN

/*
|| Create the temporary blob using the database memory buffer.
*/
dbms_lob.createtemporary(result, TRUE, dbms_lob.call);

/*
|| Loop through the input blob
*/
WHILE (pointer <= blob_length) LOOP

/*
|| Grab at most 2000 bytes from the input blob.
*/
chunk_length := LEAST(max_chunk_length,blob_length-pointer+1);
chunk := dbms_lob.substr(pi_blob,chunk_length,pointer);

/*
|| Pad any chunk (ie the last) so its length is divisible by 8 (another Oracle limitation on encryption)!.
*/
WHILE mod(chunk_length,8) !=0 LOOP
chunk := utl_raw.concat(chunk,pad);
chunk_length := chunk_length+1;
END LOOP;

/*
|| Encrypt the chunk and write it to the end of the temporary blob.
*/
dbms_lob.writeappend(result,
chunk_length,
encrypt(pi_data => chunk)
);

/*
|| Advance the pointer by the length of the last chunk.
*/
pointer := pointer + chunk_length;
END LOOP;

/*
|| All Done!
*/
RETURN result;
END;

/*
|| Function to decrypt data using the master key. Note the length of
|| pi_data, in bytes, must be at most 2000 bytes and be divisible by 8.
*/
FUNCTION decrypt(pi_data IN RAW) RETURN RAW IS
BEGIN
RETURN dbms_obfuscation_toolkit.DES3Decrypt(input => pi_data,
key => ps_encryption_key);
EXCEPTION
WHEN INTERNAL_BAD_DATA THEN
RAISE BAD_DATA;
WHEN INTERNAL_BAD_KEY THEN
RAISE BAD_KEY;
END;

/*
|| Function to decrypt a BLOB using the current encryption key.
*/
FUNCTION decrypt(pi_blob IN BLOB,
pi_size IN PLS_INTEGER) RETURN BLOB IS
/*
|| Temporary blob variable to hold the encrypted contents.
*/
result BLOB;

/*
|| Variable to hold the length of the blob.
*/
blob_length PLS_INTEGER := dbms_lob.getlength(pi_blob);

/*
|| The Oracle encryption routines can only encrypt data whose length is <=2000.
*/
max_chunk_length PLS_INTEGER := 2000;

/*
|| Variable to hold the length of the current chunk that is being encrypted.
*/
chunk_length PLS_INTEGER;

/*
|| Variable to remember which how much of the input blob has been encrypted.
*/
pointer PLS_INTEGER := 1;

BEGIN

/*
|| Create the temporary blob using the database memory buffer.
*/
dbms_lob.createtemporary(result, TRUE, dbms_lob.call);

/*
|| Loop through the input blob
*/
WHILE (pointer <= blob_length) LOOP

/*
|| Grab at most 2000 bytes from the input blob.
*/
chunk_length := LEAST(max_chunk_length,blob_length-pointer+1);

/*
|| Decrypt the chunk and write it to the end of the temporary blob.
*/
dbms_lob.writeappend(result,
chunk_length,
decrypt(pi_data => dbms_lob.substr(pi_blob,
chunk_length,
pointer
)
)
);

/*
|| Advance the pointer by the length of the last chunk.
*/
pointer := pointer + chunk_length;
END LOOP;

/*
|| Remove the padding bytes that were added when the data was encrypted.
*/
dbms_lob.trim(result,pi_size);

/*
|| All Done!
*/
RETURN result;
END;

/*
|| Procedure to clear session state of stored keys.
*/
PROCEDURE CLEAR IS
BEGIN
ps_encryption_key:=null;
END;

END;
/

and here is the PL/sql I run before running the sql stmt

DECLARE

mkey LONG RAW;

BEGIN

mkey := UTL_RAW.CAST_TO_RAW ('&&key');

my_encryption.set_master_key(mkey);

my_encryption.set_case_key(mkey,&&case_id);

END;

mkey is a 16 digit key .
and the encrypted_contents I'm trying to decrypt is a BLOB.

select my_encryption.decrypt(encrypted_contents,file_size),mime_type
from my_drafts where id = &&draft_id;

I hope this makes sense .

Ragini

  • 1986五分硬币多少钱

    Email 格式是什么样的 一共要输几个字 有字母和数字 还是都可以: 您好,一般数字和小写字母或者数字与小写字母混合都可以,至于一共可以输入几个字母或数字,这个是用邮箱提供的网站决定的,在您申请邮箱的时候它会有相应的提示 ...

    354条评论 2392人喜欢 1238次阅读 369人点赞
  • 20厘米有多少长实物图

    电源最大输出功率怎样算: PC电源功率粗略计算方法! ATX12V 1.1版以及ATX 2.03版都可以通过+5V最大输出电流值乘以10,得到大致的额定功率的值,比如+5V最大输出电流值为21,则是200W,+5V最大输出电流值为25,则...

    574条评论 2425人喜欢 4494次阅读 522人点赞
  • ppt在手机哪里

    这几个韩文是什么意思呢,怎么输入呢?输入出来就好啦,谢谢!: 라이브스타 love star 爱之星 ...

    408条评论 1207人喜欢 3920次阅读 821人点赞
  • dnf吃什么配置

    电源的最大输出功率怎么计算: 纯电阻电路,内电阻等于外电阻时,输出功率最大。 ...

    827条评论 3766人喜欢 6005次阅读 253人点赞
  • ps4gta5安装要多久

    配套功率、输入功率、输出功率分别是什么意思: 输入功率是指每台机器的总功率 输出是只电能转换为机械能 或者是是电能的最大功率 机械能是指传动轴带负载的功率 电能是指 最大可以支持多少安培 ...

    514条评论 1521人喜欢 6291次阅读 369人点赞
  • 五分的钱值多少钱

    水泵的输出功率如何计算?: 输出功率P2=QHgρQ为流量,单位m^3/sH为扬程,单位mg为重力加速度,9.8m/s^2ρ为介质比重,水的比重为1000kg/m^3 ...

    784条评论 6271人喜欢 5176次阅读 551人点赞