1.c语言中%u范围是原码0-65535,为什么输出是原码65535
2.我想问一下MD5加密现在分为16位和32位,有什么不同
3.嵌入式问题
4.cè¯è¨ï¼ 为ä»ä¹ä¼è¾åº65535ï¼
c语言中%u范围是0-65535,为什么输出是原码65535
溢出问题,你可以想想为时钟,原码当指向点钟的原码映射dll源码时候(0),往回拨一小时(-1)是原码不是点钟
同样0~, 0往回减1就是原码最大值勒,具体原理就相关于数字在计算机中存储的原码源码 补码 反码的以及存储单元大小的关系了
我想问一下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 ,对应的原码破解密码库多啊。稍微修改下。原码。原码
嵌入式问题
1.us1为 us2为 首先us1和us2是原码agc系统源码无符号形短整数,而你赋值的时候用的是负数,无符号形和普通短整数都是2个字节有符号形用的是补码表示的,而无符号形直接用无符号的原码,范围是0-(原码是一个数直接化成二进制的数,没有符号第一位是符号位。补码是源码的每位取反再加1,计算机中用补码主要是newff函数源码为了让硬件设计方便,这个是基础,所以不多说了)所以你的负数先变成补码-=,把-的补码存到内存中,而你的声明是无符号形短整数,所以使用它的时候就把它当无符号型整数的。unsigned是无符号的意思表示正整数,short int可以表示负数,供求平台 源码用补码表示。
2。 *=
3。if(si1<0)就是说如果si1是负数就执行下面的一个语句,或一个花括号里面的所有语句,由于你的si1是-就会执行{ ui-=(*(unsigned short *)&si2&(~(1L<<)))<<;cout<<ui<<endl;}如果你在这句用的是us1,由于us1是arpscan源码分析无符号型整数,所以大于等于0,所以不会执行下面这句
4。&是取地址符号,(unsigned short *)表示把取到的地址强制转换成指向无符号型整数的指针,再用*运算符取出指针指向的内容。其实这句话就是把si2转换成一个临时的unsigned short 型变量
5.1L是表示长整形的1,~(1L<<)表示长整形的1左移位,再对他按位取反结果是
6。先对si2求地址指针,并把求到的地址指针转化成无符号型整数,就是说吧si2化成临时的无符号型整数,再求~(1L<<)把得到的结果和si2的无符号型整数相与(&在位运算中是与的意思),得到的结果最后在左移位。
7。这个程序并没有什么公式,如果你能把我前面的分析看懂,就会知道这个程序其实是考你对C(虽然是C++的文件,但是基本是C的内容)中基本的一些数据转换的概念。因为这个程序在实际中根本没做什么操作,你问了这么多问题说明你对C不是很熟悉,如果你要学C的话我推荐你学谭浩强的《C程序设计》很简单也很全面,网上还有电子书,最后还有对C++的介绍。
希望我打这么多字能够帮到你。
希望能解决您的问题。
cè¯è¨ï¼ 为ä»ä¹ä¼è¾åºï¼
å ä¸ºä½ æaå®ä¹æäºunsigned short ç±»åï¼-1çè¡¥ç æ¯ï¼æ-1èµå¼ç»aï¼èaåå 为æ¯unsigned short ç±»åï¼ä»èä¸è½åæ¾è´æ°ï¼æ以æ¤æ¶æé«ä½çä¸ä¸å¨è¡¨ç¤ºè´å·ï¼èæ¯ä»£è¡¨æ°å¼ï¼æ以就åæäºï¼å¦æä½ æaå®ä¹ä¸ºintç±»åï¼å°±ä¼è¾åº-1ï¼æ³¨æï¼å¨èµå¼è¿ç¨ä¸åºè¯¥é¿å å°ä¸ä¸ªè´æ°èµç»unsigned çç±»åã