• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TimeOverlord类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.telegram.mtproto.time.TimeOverlord的典型用法代码示例。如果您正苦于以下问题:Java TimeOverlord类的具体用法?Java TimeOverlord怎么用?Java TimeOverlord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TimeOverlord类属于org.telegram.mtproto.time包,在下文中一共展示了TimeOverlord类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: generateMessageId

点赞 2

import org.telegram.mtproto.time.TimeOverlord; //导入依赖的package包/类
private synchronized long generateMessageId() {
    long messageId = TimeOverlord.getInstance().createWeakMessageId();
    if (messageId <= this.lastMessageId) {
        messageId = this.lastMessageId = this.lastMessageId + 4;
    }
    while (idGenerationTime.containsKey(messageId)) {
        messageId += 4;
    }
    this.lastMessageId = messageId;
    idGenerationTime.put(messageId, getCurrentTime());
    this.currentMessageGeneration.add(messageId);
    return messageId;
}
 

开发者ID:rubenlagus,
项目名称:TelegramApi,
代码行数:14,
代码来源:Scheduller.java

示例2: encrypt

点赞 2

import org.telegram.mtproto.time.TimeOverlord; //导入依赖的package包/类
private EncryptedMessage encrypt(int seqNo, long messageId, byte[] content) throws IOException {
    long salt = this.state.findActualSalt((int) (TimeOverlord.getInstance().getServerTime() / 1000));
    ByteArrayOutputStream messageBody = new ByteArrayOutputStream();
    writeLong(salt, messageBody);
    writeByteArray(this.session, messageBody);
    writeLong(messageId, messageBody);
    writeInt(seqNo, messageBody);
    writeInt(content.length, messageBody);
    writeByteArray(content, messageBody);

    byte[] innerData = messageBody.toByteArray();
    byte[] msgKey = substring(SHA1(innerData), 4, 16);
    int fastConfirm = readInt(SHA1(innerData)) | (1 << 31);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    writeByteArray(this.authKeyId, out);
    writeByteArray(msgKey, out);

    byte[] sha1_a = SHA1(msgKey, substring(this.authKey, 0, 32));
    byte[] sha1_b = SHA1(substring(this.authKey, 32, 16), msgKey, substring(this.authKey, 48, 16));
    byte[] sha1_c = SHA1(substring(this.authKey, 64, 32), msgKey);
    byte[] sha1_d = SHA1(msgKey, substring(this.authKey, 96, 32));

    byte[] aesKey = concat(substring(sha1_a, 0, 8), substring(sha1_b, 8, 12), substring(sha1_c, 4, 12));
    byte[] aesIv = concat(substring(sha1_a, 8, 12), substring(sha1_b, 0, 8), substring(sha1_c, 16, 4), substring(sha1_d, 0, 8));

    byte[] encoded = AES256IGEEncrypt(align(innerData, 16), aesIv, aesKey);
    writeByteArray(encoded, out);
    EncryptedMessage res = new EncryptedMessage();
    res.data = out.toByteArray();
    res.fastConfirm = fastConfirm;
    return res;
}
 

开发者ID:rubenlagus,
项目名称:TelegramApi,
代码行数:34,
代码来源:MTProto.java

示例3: generateMessageId

点赞 2

import org.telegram.mtproto.time.TimeOverlord; //导入依赖的package包/类
private synchronized long generateMessageId() {
    long messageId = TimeOverlord.getInstance().createWeakMessageId();
    if (messageId <= lastMessageId) {
        messageId = lastMessageId = lastMessageId + 4;
    }
    while (idGenerationTime.containsKey(messageId)) {
        messageId += 4;
    }
    lastMessageId = messageId;
    idGenerationTime.put(messageId, getCurrentTime());
    currentMessageGeneration.add(messageId);
    return messageId;
}
 

开发者ID:ardock,
项目名称:telegram-mt,
代码行数:14,
代码来源:Scheduller.java

示例4: encrypt

点赞 2

import org.telegram.mtproto.time.TimeOverlord; //导入依赖的package包/类
private EncryptedMessage encrypt(int seqNo, long messageId, byte[] content) throws IOException {
    long salt = state.findActualSalt((int) (TimeOverlord.getInstance().getServerTime() / 1000));
    ByteArrayOutputStream messageBody = new ByteArrayOutputStream();
    writeLong(salt, messageBody);
    writeByteArray(session, messageBody);
    writeLong(messageId, messageBody);
    writeInt(seqNo, messageBody);
    writeInt(content.length, messageBody);
    writeByteArray(content, messageBody);

    byte[] innerData = messageBody.toByteArray();
    byte[] msgKey = substring(SHA1(innerData), 4, 16);
    int fastConfirm = readInt(SHA1(innerData)) | (1 << 31);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    writeByteArray(authKeyId, out);
    writeByteArray(msgKey, out);

    byte[] sha1_a = SHA1(msgKey, substring(authKey, 0, 32));
    byte[] sha1_b = SHA1(substring(authKey, 32, 16), msgKey, substring(authKey, 48, 16));
    byte[] sha1_c = SHA1(substring(authKey, 64, 32), msgKey);
    byte[] sha1_d = SHA1(msgKey, substring(authKey, 96, 32));

    byte[] aesKey = concat(substring(sha1_a, 0, 8), substring(sha1_b, 8, 12), substring(sha1_c, 4, 12));
    byte[] aesIv = concat(substring(sha1_a, 8, 12), substring(sha1_b, 0, 8), substring(sha1_c, 16, 4), substring(sha1_d, 0, 8));

    byte[] encoded = AES256IGEEncrypt(align(innerData, 16), aesIv, aesKey);
    writeByteArray(encoded, out);
    EncryptedMessage res = new EncryptedMessage();
    res.data = out.toByteArray();
    res.fastConfirm = fastConfirm;
    return res;
}
 

开发者ID:ardock,
项目名称:telegram-mt,
代码行数:34,
代码来源:MTProto.java

示例5: addCurrentSalt

点赞 2

import org.telegram.mtproto.time.TimeOverlord; //导入依赖的package包/类
public void addCurrentSalt(long salt) {
    int time = (int) (TimeOverlord.getInstance().getServerTime() / 1000);
    mergeKnownSalts(time, new KnownSalt[]{new KnownSalt(time, time + 30 * 60, salt)});
}
 

开发者ID:rubenlagus,
项目名称:TelegramApi,
代码行数:5,
代码来源:AbsMTProtoState.java

示例6: badServerSalt

点赞 2

import org.telegram.mtproto.time.TimeOverlord; //导入依赖的package包/类
public void badServerSalt(long salt) {
    int time = (int) (TimeOverlord.getInstance().getServerTime() / 1000);
    writeKnownSalts(new KnownSalt[]{new KnownSalt(time, time + 30 * 60, salt)});
}
 

开发者ID:rubenlagus,
项目名称:TelegramApi,
代码行数:5,
代码来源:AbsMTProtoState.java

示例7: initialServerSalt

点赞 2

import org.telegram.mtproto.time.TimeOverlord; //导入依赖的package包/类
public void initialServerSalt(long salt) {
    int time = (int) (TimeOverlord.getInstance().getServerTime() / 1000);
    writeKnownSalts(new KnownSalt[]{new KnownSalt(time, time + 30 * 60, salt)});
}
 

开发者ID:rubenlagus,
项目名称:TelegramApi,
代码行数:5,
代码来源:AbsMTProtoState.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)