Exemplo n.º 1
0
        public static String generateSignature3(String appID, String appCertificate, String channelName, String unixTsStr, String randomIntStr, String uidStr, String expiredTsStr)// throws Exception
        {
            using (var ms = new MemoryStream())
                using (BinaryWriter baos = new BinaryWriter(ms))
                {
                    baos.Write(appID.GetByteArray());
                    baos.Write(unixTsStr.GetByteArray());
                    baos.Write(randomIntStr.GetByteArray());
                    baos.Write(channelName.GetByteArray());
                    baos.Write(uidStr.GetByteArray());
                    baos.Write(expiredTsStr.GetByteArray());
                    baos.Flush();

                    byte[] sign = DynamicKeyUtil.encodeHMAC(appCertificate, ms.ToArray());
                    return(DynamicKeyUtil.bytesToHex(sign));
                }
        }
Exemplo n.º 2
0
        private static String generateSignature4(String appID, String appCertificate, String channelName, String unixTsStr, String randomIntStr, String uidStr, String expiredTsStr, String serviceType) //throws Exception
        {
            using (var ms = new MemoryStream())
                using (BinaryWriter baos = new BinaryWriter(ms))
                {
                    baos.Write(serviceType.getBytes());
                    baos.Write(appID.getBytes());
                    baos.Write(unixTsStr.getBytes());
                    baos.Write(randomIntStr.getBytes());
                    baos.Write(channelName.getBytes());
                    baos.Write(uidStr.getBytes());
                    baos.Write(expiredTsStr.getBytes());

                    byte[] sign = DynamicKeyUtil.encodeHMAC(appCertificate, ms.ToArray());
                    return(DynamicKeyUtil.bytesToHex(sign));
                }


            //byte[] sign = DynamicKeyUtil.encodeHMAC(appCertificate, baos.toByteArray());
            //return DynamicKeyUtil.bytesToHex(sign);
        }