将varchar数据更新为二进制(16) [英] update varchar data to binary(16)

查看:178
本文介绍了将varchar数据更新为二进制(16)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我的密码列具有varchar(50)数据类型.现在,我创建了一个新列NewPassword binary(16).
我想在NewPassword列中将密码varchar数据转换为二进制(16)格式.

我该怎么办?

谢谢.

Hello,

I have my password column with varchar(50) datatype. now i have created a new column NewPassword binary(16).
I want to convert password varchar data to binary(16) format in NewPassword column.

How can i do it?

Thanks.

推荐答案

我们无法回答.

首先,无法将50个字符压缩为16个字节:即使您只有AZ和几个其他字符,也无法保证将其压缩为26个字符(称其为32个字符)数学上很容易)需要50 * 5位= 250,而16个字节只有128位.

其次,唯一获得哈希的方法是对其进行哈希处理-由于我们不知道您正在考虑使用哪种哈希算法,因此我们无法告诉您如何在SQL中执行此操作-我不会即使可以,我个人也想使用真实"代码来确保在我检查代码时可以正常使用.
We can''t answer that.

Firstly, there is no way to pack 50 characters into 16 bytes: even if you only had A-Z and a couple of other characters in there, you couldn''t guarantee to "squash" it down: 26 characters (call it 32 to make the math easy) needs 50 * 5 bits = 250 and 16 bytes only has 128 bits.

Secondly, the only way you will get it in there is to hash it - and since we have no idea what hashing algorithm you are thinking of useing, we can''t tell you how to do it in SQL - I wouldn''t even if I could, personally as I''d want to use the "real" code to make sure it worked when I checked them.


这篇关于将varchar数据更新为二进制(16)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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