1.4位16进制数是码位什么意思?
2.写出下列数据的原码和补码(取字长为8位二进制) (1),30 (2),原码-30 (3),码位-95 (4),原码102
3.我想问一下MD5加密现在分为16位和32位,码位有什么不同
4位16进制数是什么意思?
一个十六进制数对应四个二进制数,4*4=。码位十六进制数是原码由0-9A-F组成的,就像十进制数由0-9组成一样,码位四位十进制数是原码-,而四位十六进制数是码位-FFFF。
一位进制数可以表示从0到F的原码(十进制的)十六个数,四位就可以表示从0到FFFF的码位(十进制)个数(的4次方);
一位二进制数可以表示从0到1的(十进制)两个数,十六位就可以表示从0到的原码(十进制)个数(2的次方),是码位白金源码分享2的四次方。
十六进制(hexadecimal)是计算机中数据的一种表示方法,的规则是“逢十六进一”。
十六进制数具有下列两个特点:英文字母A,B,C,D,E,F分别表示数字~;计数到F后,再增加1个,就进位。
十六进制数就是4位二进制数。二进制反码是二进制逐位取反。比如反码就是,十六进制只是jvm 源码 下载表示形式不一样。是A,是5.A的反码就是5,是B,反码是4,即。
进制即逢进1,每一位上可以是从小到大为0、1、2、3、4、5、6、7、vuejs源码详解8、9、A、B、C、D、E、F共个大小不同的数。进制转换即进制与其他不同进制之间的换算转换,常见如2进制、8进制、进制等进制。
由于在二进制的表示方法中,每四位所表示的淘宝轮播源码数的最大值对应进制的,即进制每一位上最大值,所以,可以得出简便的转换方法,将进制上每一位分别对应二进制上四位进行转换。
一个十六进制数字表示的范围是十进制数0到,所以,用字母A到F来代表十进制数到。
十六进制数中,每一个数字位都代表了的幂。这有助于计算一个十六进制整数的十进制值。假设用下标来对一个包含4个数字的十六进制数编号D3D2D1D0。
下式计算了这个整数的十进制值:
dec=(D3X)+(D2X)+(D1X)+(D0x)。
这个表达式可以推广到任意n位数的十六进制整数:
dec=(Dn-1Xn-1)+(Dn-2xn-2)+…+(D1X)+(D0x)
一般情况下,可以通过公式把基数为B的任何n位整数转换为十进制数:
dec=(Dn-1XBn-1)+(Dn-2XBn-2)+…+(D1XB1)+(D0xB0)。
比如,十六进制数就等于(1x)+(2x)+(3X)+(4x),也就是十进制数。
同样,十六进制数3BA4等于(3x)+(x)+(x)+(4x),也就是十进制数。
无符号十进制整数转换到十六进制数的过程是,把这个十进制数反复除以,每次取余数作为一个十六进制数字。
一般都是用二进制存储,十六进制只是为了给人们看的时候方便一点,毕竟二进制直接写出来太长了。
为什么不用十进制表示,因为二进制转十进制需要经过一系列换算,而且长度还不一定(四位数的二进制,写成十进制,有可能是一位数,也有可能是两位数);
而二进制转十六进制,每四位数的二进制都对应一位数的十六进制,直接通过查表就能转换,有经验的人甚至可以直接口算。
所以,计算机内部都是用的二进制,但需要查看源码的时候,用十六进制写出来,不至于写出来太长,反推回去也很方便。
所以,当涉及到源码时,一般都习惯用十六进制表示。
扩展资料:
十六进制在数学中是一种逢进1的进位制。一般用数字0到9和字母A到F(或a~f)表示,其中:A~F表示~,这些称作十六进制数字。
例如十进制数,在二进制写作,在进制写作。在历史上,中国曾经在重量单位上使用过进制,比如,规定两为一斤。
如今的进制则普遍应用在计算机领域,这是因为将4个位元(Bit)化成单独的进制数字不太困难。1字节可以表示成2个连续的进制数字。可是,这种混合表示法容易令人混淆,因此需要一些字首、字尾或下标来显示。
参考资料:
写出下列数据的原码和补码(取字长为8位二进制) (1), (2),- (3),- (4),
(1) 原码: ,补码:
(2)- 原码: ,补码:
(3)- 原码: ,补码:
(4)原码: ,补码:
我想问一下MD5加密现在分为位和位,有什么不同
给你看看流行的MD5加密源代码你就知道了。
<%
Private Const BITS_TO_A_BYTE = 8
Private Const BYTES_TO_A_WORD = 4
Private Const BITS_TO_A_WORD =
Private m_lOnBits()
Private m_l2Power()
Private Function LShift(lValue, iShiftBits)
If iShiftBits = 0 Then
LShift = lValue
Exit Function
ElseIf iShiftBits = Then
If lValue And 1 Then
LShift = &H
Else
LShift = 0
End If
Exit Function
ElseIf iShiftBits < 0 Or iShiftBits > Then
Err.Raise 6
End If
If (lValue And m_l2Power( - iShiftBits)) Then
LShift = ((lValue And m_lOnBits( - (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H
Else
LShift = ((lValue And m_lOnBits( - iShiftBits)) * m_l2Power(iShiftBits))
End If
End Function
Private Function RShift(lValue, iShiftBits)
If iShiftBits = 0 Then
RShift = lValue
Exit Function
ElseIf iShiftBits = Then
If lValue And &H Then
RShift = 1
Else
RShift = 0
End If
Exit Function
ElseIf iShiftBits < 0 Or iShiftBits > Then
Err.Raise 6
End If
RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits)
If (lValue And &H) Then
RShift = (RShift Or (&H \ m_l2Power(iShiftBits - 1)))
End If
End Function
Private Function RotateLeft(lValue, iShiftBits)
RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, ( - iShiftBits))
End Function
Private Function AddUnsigned(lX, lY)
Dim lX4
Dim lY4
Dim lX8
Dim lY8
Dim lResult
lX8 = lX And &H
lY8 = lY And &H
lX4 = lX And &H
lY4 = lY And &H
lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF)
If lX4 And lY4 Then
lResult = lResult Xor &H Xor lX8 Xor lY8
ElseIf lX4 Or lY4 Then
If lResult And &H Then
lResult = lResult Xor &HC Xor lX8 Xor lY8
Else
lResult = lResult Xor &H Xor lX8 Xor lY8
End If
Else
lResult = lResult Xor lX8 Xor lY8
End If
AddUnsigned = lResult
End Function
Private Function md5_F(x, y, z)
md5_F = (x And y) Or ((Not x) And z)
End Function
Private Function md5_G(x, y, z)
md5_G = (x And z) Or (y And (Not z))
End Function
Private Function md5_H(x, y, z)
md5_H = (x Xor y Xor z)
End Function
Private Function md5_I(x, y, z)
md5_I = (y Xor (x Or (Not z)))
End Function
Private Sub md5_FF(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_F(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub md5_GG(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_G(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub md5_HH(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_H(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub md5_II(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_I(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Function ConvertToWordArray(sMessage)
Dim lMessageLength
Dim lNumberOfWords
Dim lWordArray()
Dim lBytePosition
Dim lByteCount
Dim lWordCount
Const MODULUS_BITS =
Const CONGRUENT_BITS =
lMessageLength = Len(sMessage)
lNumberOfWords = (((lMessageLength + ((MODULUS_BITS - CONGRUENT_BITS) \ BITS_TO_A_BYTE)) \ (MODULUS_BITS \ BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS \ BITS_TO_A_WORD)
ReDim lWordArray(lNumberOfWords - 1)
lBytePosition = 0
lByteCount = 0
Do Until lByteCount >= lMessageLength
lWordCount = lByteCount \ BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition)
lByteCount = lByteCount + 1
Loop
lWordCount = lByteCount \ BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(&H, lBytePosition)
lWordArray(lNumberOfWords - 2) = LShift(lMessageLength, 3)
lWordArray(lNumberOfWords - 1) = RShift(lMessageLength, )
ConvertToWordArray = lWordArray
End Function
Private Function WordToHex(lValue)
Dim lByte
Dim lCount
For lCount = 0 To 3
lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits(BITS_TO_A_BYTE - 1)
WordToHex = WordToHex & Right("0" & Hex(lByte), 2)
Next
End Function
Public Function MD5(sMessage)
m_lOnBits(0) = CLng(1)
m_lOnBits(1) = CLng(3)
m_lOnBits(2) = CLng(7)
m_lOnBits(3) = CLng()
m_lOnBits(4) = CLng()
m_lOnBits(5) = CLng()
m_lOnBits(6) = CLng()
m_lOnBits(7) = CLng()
m_lOnBits(8) = CLng()
m_lOnBits(9) = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_lOnBits() = CLng()
m_l2Power(0) = CLng(1)
m_l2Power(1) = CLng(2)
m_l2Power(2) = CLng(4)
m_l2Power(3) = CLng(8)
m_l2Power(4) = CLng()
m_l2Power(5) = CLng()
m_l2Power(6) = CLng()
m_l2Power(7) = CLng()
m_l2Power(8) = CLng()
m_l2Power(9) = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
m_l2Power() = CLng()
Dim x
Dim k
Dim AA
Dim BB
Dim CC
Dim DD
Dim a
Dim b
Dim c
Dim d
Const S = 7
Const S =
Const S =
Const S =
Const S = 5
Const S = 9
Const S =
Const S =
Const S = 4
Const S =
Const S =
Const S =
Const S = 6
Const S =
Const S =
Const S =
x = ConvertToWordArray(sMessage)
a = &H
b = &HEFCDAB
c = &HBADCFE
d = &H
For k = 0 To UBound(x) Step
AA = a
BB = b
CC = c
DD = d
md5_FF a, b, c, d, x(k + 0), S, &HDAA
md5_FF d, a, b, c, x(k + 1), S, &HE8C7B
md5_FF c, d, a, b, x(k + 2), S, &HDB
md5_FF b, c, d, a, x(k + 3), S, &HC1BDCEEE
md5_FF a, b, c, d, x(k + 4), S, &HFC0FAF
md5_FF d, a, b, c, x(k + 5), S, &HCA
md5_FF c, d, a, b, x(k + 6), S, &HA
md5_FF b, c, d, a, x(k + 7), S, &HFD
md5_FF a, b, c, d, x(k + 8), S, &HD8
md5_FF d, a, b, c, x(k + 9), S, &H8BF7AF
md5_FF c, d, a, b, x(k + ), S, &HFFFF5BB1
md5_FF b, c, d, a, x(k + ), S, &HCD7BE
md5_FF a, b, c, d, x(k + ), S, &H6B
md5_FF d, a, b, c, x(k + ), S, &HFD
md5_FF c, d, a, b, x(k + ), S, &HAE
md5_FF b, c, d, a, x(k + ), S, &HB
md5_GG a, b, c, d, x(k + 1), S, &HFE
md5_GG d, a, b, c, x(k + 6), S, &HCB
md5_GG c, d, a, b, x(k + ), S, &HE5A
md5_GG b, c, d, a, x(k + 0), S, &HE9B6C7AA
md5_GG a, b, c, d, x(k + 5), S, &HDFD
md5_GG d, a, b, c, x(k + ), S, &H
md5_GG c, d, a, b, x(k + ), S, &HD8A1E
md5_GG b, c, d, a, x(k + 4), S, &HE7D3FBC8
md5_GG a, b, c, d, x(k + 9), S, &HE1CDE6
md5_GG d, a, b, c, x(k + ), S, &HCD6
md5_GG c, d, a, b, x(k + 3), S, &HF4DD
md5_GG b, c, d, a, x(k + 8), S, &HAED
md5_GG a, b, c, d, x(k + ), S, &HA9E3E
md5_GG d, a, b, c, x(k + 2), S, &HFCEFA3F8
md5_GG c, d, a, b, x(k + 7), S, &HFD9
md5_GG b, c, d, a, x(k + ), S, &H8D2A4C8A
md5_HH a, b, c, d, x(k + 5), S, &HFFFA
md5_HH d, a, b, c, x(k + 8), S, &HF
md5_HH c, d, a, b, x(k + ), S, &H6D9D
md5_HH b, c, d, a, x(k + ), S, &HFDEC
md5_HH a, b, c, d, x(k + 1), S, &HA4BEEA
md5_HH d, a, b, c, x(k + 4), S, &H4BDECFA9
md5_HH c, d, a, b, x(k + 7), S, &HF6BB4B
md5_HH b, c, d, a, x(k + ), S, &HBEBFBC
md5_HH a, b, c, d, x(k + ), S, &HB7EC6
md5_HH d, a, b, c, x(k + 0), S, &HEAAFA
md5_HH c, d, a, b, x(k + 3), S, &HD4EF
md5_HH b, c, d, a, x(k + 6), S, &HD
md5_HH a, b, c, d, x(k + 9), S, &HD9D4D
md5_HH d, a, b, c, x(k + ), S, &HE6DBE5
md5_HH c, d, a, b, x(k + ), S, &H1FACF8
md5_HH b, c, d, a, x(k + 2), S, &HC4AC
md5_II a, b, c, d, x(k + 0), S, &HF
md5_II d, a, b, c, x(k + 7), S, &HAFF
md5_II c, d, a, b, x(k + ), S, &HABA7
md5_II b, c, d, a, x(k + 5), S, &HFCA
md5_II a, b, c, d, x(k + ), S, &HBC3
md5_II d, a, b, c, x(k + 3), S, &H8F0CCC
md5_II c, d, a, b, x(k + ), S, &HFFEFFD
md5_II b, c, d, a, x(k + 1), S, &HDD1
md5_II a, b, c, d, x(k + 8), S, &H6FAE4F
md5_II d, a, b, c, x(k + ), S, &HFE2CE6E0
md5_II c, d, a, b, x(k + 6), S, &HA
md5_II b, c, d, a, x(k + ), S, &H4EA1
md5_II a, b, c, d, x(k + 4), S, &HFE
md5_II d, a, b, c, x(k + ), S, &HBD3AF
md5_II c, d, a, b, x(k + 2), S, &H2AD7D2BB
md5_II b, c, d, a, x(k + 9), S, &HEBD
a = AddUnsigned(a, AA)
b = AddUnsigned(b, BB)
c = AddUnsigned(c, CC)
d = AddUnsigned(d, DD)
Next
'MD5 = LCase(WordToHex(a) & WordToHex(b) & WordToHex(c) & WordToHex(d))
MD5=LCase(WordToHex(b) & WordToHex(c)) 'I crop this to fit byte database password :D
End Function
%>
一般不提倡直接原封不动的调用MD5 ,对应的破解密码库多啊。稍微修改下。。