private String getParams() { StringBuilder sb = new StringBuilder(); String appId = AppConfig.getAPPid(); sb.Append("?app_id=" + appId); String scope = ""; sb.Append("&scope=" + scope); String state = "12345678"; sb.Append("&state=" + state); String responseType = "code"; sb.Append("&response_type=" + responseType); String time = TimeParser.GetTimeStamp(DateTime.Now); sb.Append("×tamp=" + time); List <System.String> array = new List <System.String>(); string APPsecret = AppConfig.getAPPsecret(); array.Add(APPsecret); array.Add(appId); array.Add(responseType); array.Add(time); array.Add(state); array.Add(scope); sb.Append("&checksum=" + SHAUtils.getSHACode(array.ToArray())); return(sb.ToString()); }
private String getParams() { String appId = AppConfig.getAPPid(); String grantType = "authorization_code"; String code = mAuthorizeCode; String time = TimeParser.GetTimeStamp(DateTime.Now); List <System.String> array = new List <System.String>(); string APPsecret = AppConfig.getAPPsecret(); array.Add(APPsecret); array.Add(appId); array.Add(grantType); array.Add(code); array.Add(time); String checkSum = SHAUtils.getSHACode(array.ToArray()); StringBuilder sb = new StringBuilder(); sb.Append("?app_id=" + appId); sb.Append("&grant_type=" + grantType); sb.Append("&code=" + code); sb.Append("×tamp=" + time); sb.Append("&checksum=" + checkSum); return(sb.ToString()); }
private static String getSHA() { List <System.String> array = new List <System.String>(); array.Add("bd5cdb1a49ad26878a9ca800fdd53956c6b61882"); array.Add("818ea8c3572ec6277fe2bf0e8e58ffa274ca11a0"); array.Add("UKjPas12"); array.Add("code"); array.Add("1528937315037"); String[] arr = array.ToArray(); return(SHAUtils.getSHACode(arr)); }
/* SHA512 finalization. Ends an SHA512 message-digest operation, writing * the message digest. */ public override byte[] HashFinal() { byte[] pad; int padLen; ulong bitCount; byte[] hash = new byte[64]; // HashSizeValue = 512 /* Compute padding: 80 00 00 ... 00 00 <bit count> */ padLen = 128 - (int)(_count & 0x7f); if (padLen <= 16) { padLen += 128; } pad = new byte[padLen]; pad[0] = 0x80; // Convert count to bit count bitCount = _count * 8; // If we ever have UInt128 for bitCount, then these need to be uncommented. // Note that C# only looks at the low 6 bits of the shift value for ulongs, // so >>0 and >>64 are equal! //pad[padLen-16] = (byte) ((bitCount >> 120) & 0xff); //pad[padLen-15] = (byte) ((bitCount >> 112) & 0xff); //pad[padLen-14] = (byte) ((bitCount >> 104) & 0xff); //pad[padLen-13] = (byte) ((bitCount >> 96) & 0xff); //pad[padLen-12] = (byte) ((bitCount >> 88) & 0xff); //pad[padLen-11] = (byte) ((bitCount >> 80) & 0xff); //pad[padLen-10] = (byte) ((bitCount >> 72) & 0xff); //pad[padLen-9] = (byte) ((bitCount >> 64) & 0xff); pad[padLen - 8] = (byte)((bitCount >> 56) & 0xff); pad[padLen - 7] = (byte)((bitCount >> 48) & 0xff); pad[padLen - 6] = (byte)((bitCount >> 40) & 0xff); pad[padLen - 5] = (byte)((bitCount >> 32) & 0xff); pad[padLen - 4] = (byte)((bitCount >> 24) & 0xff); pad[padLen - 3] = (byte)((bitCount >> 16) & 0xff); pad[padLen - 2] = (byte)((bitCount >> 8) & 0xff); pad[padLen - 1] = (byte)((bitCount >> 0) & 0xff); /* Digest padding */ HashCore(pad, 0, pad.Length); /* Store digest */ SHAUtils.QuadWordToBigEndian(hash, _stateSHA512, 8); return(hash); }
/* SHA384 finalization. Ends an SHA384 message-digest operation, writing * the message digest. */ public override byte[] HashFinal() { byte[] pad; int padLen; ulong bitCount; byte[] hash = new byte[48]; // HashSizeValue = 384 /* Compute padding: 80 00 00 ... 00 00 <bit count> */ padLen = 128 - (int)(_count & 0x7f); if (padLen <= 16) { padLen += 128; } pad = new byte[padLen]; pad[0] = 0x80; // Convert count to bit count bitCount = _count * 8; // bitCount is at most 8 * 128 = 1024. Its representation as a 128-bit number has all bits set to zero // except eventually the 11 lower bits //pad[padLen-16] = (byte) ((bitCount >> 120) & 0xff); //pad[padLen-15] = (byte) ((bitCount >> 112) & 0xff); //pad[padLen-14] = (byte) ((bitCount >> 104) & 0xff); //pad[padLen-13] = (byte) ((bitCount >> 96) & 0xff); //pad[padLen-12] = (byte) ((bitCount >> 88) & 0xff); //pad[padLen-11] = (byte) ((bitCount >> 80) & 0xff); //pad[padLen-10] = (byte) ((bitCount >> 72) & 0xff); //pad[padLen-9] = (byte) ((bitCount >> 64) & 0xff); pad[padLen - 8] = (byte)((bitCount >> 56) & 0xff); pad[padLen - 7] = (byte)((bitCount >> 48) & 0xff); pad[padLen - 6] = (byte)((bitCount >> 40) & 0xff); pad[padLen - 5] = (byte)((bitCount >> 32) & 0xff); pad[padLen - 4] = (byte)((bitCount >> 24) & 0xff); pad[padLen - 3] = (byte)((bitCount >> 16) & 0xff); pad[padLen - 2] = (byte)((bitCount >> 8) & 0xff); pad[padLen - 1] = (byte)((bitCount >> 0) & 0xff); /* Digest padding */ HashCore(pad, 0, pad.Length); /* Store digest */ SHAUtils.QuadWordToBigEndian(hash, _stateSHA384, 6); return(hash); }
/* SHA256 finalization. Ends an SHA256 message-digest operation, writing * the message digest. */ public override byte[] HashFinal() { byte[] pad; int padLen; long bitCount; byte[] hash = new byte[32]; // HashSizeValue = 256 /* Compute padding: 80 00 00 ... 00 00 <bit count> */ padLen = 64 - (int)(_count & 0x3f); if (padLen <= 8) { padLen += 64; } pad = new byte[padLen]; pad[0] = 0x80; // Convert count to bit count bitCount = _count * 8; pad[padLen - 8] = (byte)((bitCount >> 56) & 0xff); pad[padLen - 7] = (byte)((bitCount >> 48) & 0xff); pad[padLen - 6] = (byte)((bitCount >> 40) & 0xff); pad[padLen - 5] = (byte)((bitCount >> 32) & 0xff); pad[padLen - 4] = (byte)((bitCount >> 24) & 0xff); pad[padLen - 3] = (byte)((bitCount >> 16) & 0xff); pad[padLen - 2] = (byte)((bitCount >> 8) & 0xff); pad[padLen - 1] = (byte)((bitCount >> 0) & 0xff); /* Digest padding */ HashCore(pad, 0, pad.Length); /* Store digest */ SHAUtils.DWORDToBigEndian(hash, _stateSHA256, 8); return(hash); }
protected string getParams() { String appId = AppConfig.getAPPid(); String time = TimeParser.GetTimeStamp(DateTime.Now); List <System.String> array = new List <System.String>(); string APPsecret = AppConfig.getAPPsecret(); array.Add(APPsecret); array.Add(appId); array.Add(mAcessTokenandOpendid.acessToken); array.Add(time); String checkSum = SHAUtils.getSHACode(array.ToArray()); StringBuilder sb = new StringBuilder(); sb.Append("?app_id=" + appId); sb.Append("&acess_token=" + mAcessTokenandOpendid.acessToken); sb.Append("×tamp=" + time); sb.Append("&checksum=" + checkSum); return(sb.ToString()); }
private static unsafe void SHATransform(ulong *expandedBuffer, ulong *state, byte *block) { ulong a, b, c, d, e, f, g, h; ulong aa, bb, cc, dd, ee, ff, hh, gg; ulong T1; a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4]; f = state[5]; g = state[6]; h = state[7]; // fill in the first 16 blocks of W. SHAUtils.QuadWordFromBigEndian(expandedBuffer, 16, block); SHA512Expand(expandedBuffer); /* Apply the SHA512 compression function */ // We are trying to be smart here and avoid as many copies as we can // The perf gain with this method over the straightforward modify and shift // forward is >= 20%, so it's worth the pain for (int j = 0; j < 80;) { T1 = h + Sigma_1(e) + Ch(e, f, g) + _K[j] + expandedBuffer[j]; ee = d + T1; aa = T1 + Sigma_0(a) + Maj(a, b, c); j++; T1 = g + Sigma_1(ee) + Ch(ee, e, f) + _K[j] + expandedBuffer[j]; ff = c + T1; bb = T1 + Sigma_0(aa) + Maj(aa, a, b); j++; T1 = f + Sigma_1(ff) + Ch(ff, ee, e) + _K[j] + expandedBuffer[j]; gg = b + T1; cc = T1 + Sigma_0(bb) + Maj(bb, aa, a); j++; T1 = e + Sigma_1(gg) + Ch(gg, ff, ee) + _K[j] + expandedBuffer[j]; hh = a + T1; dd = T1 + Sigma_0(cc) + Maj(cc, bb, aa); j++; T1 = ee + Sigma_1(hh) + Ch(hh, gg, ff) + _K[j] + expandedBuffer[j]; h = aa + T1; d = T1 + Sigma_0(dd) + Maj(dd, cc, bb); j++; T1 = ff + Sigma_1(h) + Ch(h, hh, gg) + _K[j] + expandedBuffer[j]; g = bb + T1; c = T1 + Sigma_0(d) + Maj(d, dd, cc); j++; T1 = gg + Sigma_1(g) + Ch(g, h, hh) + _K[j] + expandedBuffer[j]; f = cc + T1; b = T1 + Sigma_0(c) + Maj(c, d, dd); j++; T1 = hh + Sigma_1(f) + Ch(f, g, h) + _K[j] + expandedBuffer[j]; e = dd + T1; a = T1 + Sigma_0(b) + Maj(b, c, d); j++; } state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; state[5] += f; state[6] += g; state[7] += h; }