Beispiel #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));
                }
        }
Beispiel #2
0
        public static byte[] generateSignature(String appCertificate
            , String appID
            , String channelName
            , String uid
            , byte[] message)
        {
            using (var ms = new MemoryStream())
            using (BinaryWriter baos = new BinaryWriter(ms))
            {
                baos.Write(appID.GetByteArray());
                baos.Write(channelName.GetByteArray());
                baos.Write(uid.GetByteArray());
                baos.Write(message);
                baos.Flush();

                byte[] sign = DynamicKeyUtil.encodeHMAC(appCertificate, ms.ToArray(), "SHA256");
                return sign;
            }
        }
        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);
        }