Datetime. datetime. strftime (datetime. datetime. now (), '% Y % m % d % H % M % s ') |
DateTime. Now. ToString ("yyyyMMddHHmmss ") |
Random. choice ('123 ') |
Random. Next (1, 9). ToString () |
Struct. pack ('> I', int (time. time ())) |
TimeSpan ts = DateTime. UtcNow-new DateTime (1970, 1, 1, 0, 0, 0, 0 ); Byte [] timeSpanBytes = BitConverter. GetBytes (Convert. ToUInt32 (ts )); If (BitConverter. IsLittleEndian) { Array. Reverse (timeSpanBytes ); } |
Binascii. hexlify (AB) |
BitConverter. ToString (timeSpanBytes) |
Random. randint (0, 100000000 )) |
Random random = new Random (DateTime. Now. Millisecond ); Random. Next (0, 100000000) |
Myhmac = hmac. new ("d6fc3a4a06adbde89223bvefedc24fecde188aaa9161", digestmod = hashlib. sha1) Myhmac. update (binascii. unhexlify ('57b47f0a1b8a35a00300fbe94bcf ')) Encode = base64.b64encode (myhmac. digest ()) |
String hexData = "57b47f0a1b8a35a00300fbe94bcf "; If (hexvalue. Length % 2! = 0) { Hexvalue = "0" + hexvalue; } Int len = hexvalue. Length/2; Byte [] bytes = new byte [len]; For (int I = 0; I <len; I ++) { String byteString = hexvalue. Substring (2 * I, 2 ); Bytes [I] = Convert. ToByte (byteString, 16 ); }
String str = "d6fc3a4a06adbde89223bvefedc24fecde188aaa9161 "; ASCIIEncoding encoder = new ASCIIEncoding (); Byte [] code = encoder. GetBytes (str ); HMACSHA1 hmSha1 = new HMACSHA1 (code ); Byte [] hmBytes = hmSha1.ComputeHash (bytes ); String encode = Convert. ToBase64String (hmBytes ); |
Bytes = binascii. unhexlify (hexvalue) |
If (hexvalue. Length % 2! = 0) { Hexvalue = "0" + hexvalue; } Int len = hexvalue. Length/2; Byte [] bytes = new byte [len]; For (int I = 0; I <len; I ++) { String byteString = hexvalue. Substring (2 * I, 2 ); Bytes [I] = Convert. ToByte (byteString, 16 ); } Return bytes; |
Var hmac = hashlib. md5 ('f % s % s' % (time_str, device_no). hexdigest () |
Var md5 = new MD5CryptoServiceProvider (); Byte [] m = md5.ComputeHash (Encoding. UTF8.GetBytes ($ "F {timeSpan} {deviceNO }")); Var hmac = BitConverter. ToString (m). Replace ("-", ""). ToLower (); |
Buf_size = 0x1000 Raw_memory = bytearray (buf_size) Ctypes_raw_type = (ctypes. c_char * buf_size) Ctypes_raw_memory = ctypes_raw_type.from_buffer (raw_memory) EncLen = Objdll. encode (byref (ctypes_raw_memory), buf_size, inputCode, len (inputCode) # Objdll. encode is c ++ call # Return raw_memory [: encLen] |
IntPtr data = Marshal. StringToHGlobalAnsi (inputCode ); Byte [] aaab = new byte [4096]; int aa = encode (aaab, 4096, data, inputCode. Length); byte [] byteNew = new byte [aa]; For (int I = 0; I <aa; I ++) { ByteNew [I] = aaab [I]; } Return byteNew; |
SzPara = create_string_buffer ('/0' * buf_size) DecLen = Objdll. decode (byref (szPara), buf_size, decodeInput, len (decodeInput )) # Call Objdll. encode as c ++ # Return szPara. value [: decLen] |
Bytes [] outsting = new byte [0x1000]; Int encLen = decode (outsting, outsting. Length, inputCode, inputCode. Length ); String ret = Encoding. UTF8.GetString (outsting, 0, encLen ); Return ret; |
Json. loads (test) |
JsonConvert. DeserializeObject (test) |