Home > database >  Ask bosses answer questions about the ASCII
Ask bosses answer questions about the ASCII

Time:04-22

Recently said in an ASCII file see password,

Want to ask bosses 1234567890 and after each character conversion hex file 313331373133313 f3139 said 1234567890 is not the same, is this why?

Corresponding and admin, file with 61656 f6a6a said, and turns into the string of ASCII characters is aeojj, a111 with 6 a303030 said,

Feel in different position for each character in the string, ASCII is different also, hope to have a big solve, thank you very much!

CodePudding user response:

Demo:
 
Declare @ ValStr varchar (Max)='1234567890'

Declare @ Val varbinary (8)

The set @ Val=cast (@ ValStr as varbinary (Max)), is converted to binary
- select @ Val

Turn - binary hexadecimal
Declare @ re varchar (Max),
@ I int

Select @ re=', @ I=datalength (@ Val)
While @ i> 0
The begin
Select @ re=the substring (' 0123456789 abcdef, substring (@ Val, @ I, 1)/16 + 1, 1)
+ the substring (' 0123456789 abcdef, substring (@ Val, @ I, 1) % (16 + 1, 1)
+ @ re
@ I=@ I - 1
End
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Select @ re


Note that the value of the incoming is varchar (Max), rather than bigint, first turn binary, hexadecimal conversion, then do
  • Related